Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/broadcast-channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ export interface BroadcastChannelData {
projectIds: string[];
settings?: boolean;
}
class NoOpBroadcastChannel {
constructor() {}
postMessage(_data: unknown) {}
addEventListener(_type: string, _handler: (e: MessageEvent) => void) {}
removeEventListener(_type: string, _handler: (e: MessageEvent) => void) {}
close() {}
}

// Used to keep project state synced between open tabs / windows.
export const broadcastChannel = new BroadcastChannel("ml");
// Broadcast channel is not supported for older browsers/iOS versions, so a
// no-op version is used to avoid throwing an error.
// TODO: Revisit making project state syncing work for older web browsers.
export const broadcastChannel =
typeof BroadcastChannel === "undefined"
? new NoOpBroadcastChannel()
: new BroadcastChannel("ml");
Loading