MCPcopy Index your code
hub / github.com/nukeop/nuclear / useSSESync

Function useSSESync

packages/player/src/remoteControl/useSSESync.ts:4–16  ·  view source on GitHub ↗
(source: EventSource | null)

Source from the content-addressed store, hash-verified

2import { EventSourceEvent, useEventSourceListener } from './useEventSource';
3
4export const useSSESync = (source: EventSource | null) => {
5 useEventSourceListener(source, ['queue'], (event: EventSourceEvent) => {
6 useRemoteStore.getState().setQueue(JSON.parse(event.data));
7 });
8
9 useEventSourceListener(source, ['playback'], (event: EventSourceEvent) => {
10 useRemoteStore.getState().setPlayback(JSON.parse(event.data));
11 });
12
13 useEventSourceListener(source, ['settings'], (event: EventSourceEvent) => {
14 useRemoteStore.getState().setSettings(JSON.parse(event.data));
15 });
16};

Callers 1

useRemoteStateFunction · 0.90

Calls 2

useEventSourceListenerFunction · 0.90
getStateMethod · 0.80

Tested by

no test coverage detected