1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-21 03:43:58 +00:00
Files
browser/apps/desktop/src/platform/utils/from-ipc-messaging.ts
Addison Beck 56a3b14583 Introduce eslint errors for risky/circular imports (#14804)
* first draft at an idea dependency graph

* ignore existing errors

* remove conflicting rule regarding internal platform logic in libs

* review: allow components to import from platform
2025-05-23 08:01:25 -04:00

18 lines
769 B
TypeScript

import { fromEventPattern, share } from "rxjs";
import { Message } from "@bitwarden/common/platform/messaging";
// This import has been flagged as unallowed for this class. It may be involved in a circular dependency loop.
// eslint-disable-next-line no-restricted-imports
import { tagAsExternal } from "@bitwarden/common/platform/messaging/internal";
/**
* Creates an observable that when subscribed to will listen to messaging events through IPC.
* @returns An observable stream of messages.
*/
export const fromIpcMessaging = () => {
return fromEventPattern<Message<Record<string, unknown>>>(
(handler) => ipc.platform.onMessage.addListener(handler),
(handler) => ipc.platform.onMessage.removeListener(handler),
).pipe(tagAsExternal(), share());
};