refactor(session): extract sharing orchestration (#21759)

This commit is contained in:
Kit Langton
2026-04-09 21:47:48 -04:00
committed by GitHub
parent 0970b102e1
commit 16c60c9ee7
6 changed files with 100 additions and 44 deletions
+5 -1
View File
@@ -159,7 +159,10 @@ export namespace ShareNext {
if (disabled) return cache
const watch = <D extends { type: string }>(def: D, fn: (evt: { properties: any }) => Effect.Effect<void>) =>
const watch = <D extends { type: string }>(
def: D,
fn: (evt: { properties: any }) => Effect.Effect<void, unknown>,
) =>
bus.subscribe(def as never).pipe(
Stream.runForEach((evt) =>
fn(evt).pipe(
@@ -194,6 +197,7 @@ export namespace ShareNext {
yield* watch(Session.Event.Diff, (evt) =>
sync(evt.properties.sessionID, [{ type: "session_diff", data: evt.properties.diff }]),
)
yield* watch(Session.Event.Deleted, (evt) => remove(evt.properties.sessionID))
return cache
}),