MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / start

Function start

ui/src/live/createLiveStore.ts:95–110  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

93 }
94
95 function start() {
96 if (cleanup) return
97 lastEventTs = Date.now()
98 cleanup = opts.subscribe({ apply })
99
100 visibilityHandler = () => {
101 if (document.visibilityState !== 'visible') return
102 if (Date.now() - lastEventTs > stale) {
103 // Connection might have died silently while backgrounded — take
104 // the optimistic stance and reconnect. Worst case we drop a few
105 // duplicate events; best case we recover from a zombie socket.
106 reconnect()
107 }
108 }
109 document.addEventListener('visibilitychange', visibilityHandler)
110 }
111
112 function stop() {
113 cleanup?.()

Callers 2

reconnectFunction · 0.70
bumpRefFunction · 0.70

Calls 3

reconnectFunction · 0.85
subscribeMethod · 0.65
addEventListenerMethod · 0.65

Tested by

no test coverage detected