| 164 | if (disabled) return cache |
| 165 | |
| 166 | const watch = <D extends EventV2.Definition>( |
| 167 | def: D, |
| 168 | fn: (data: EventV2.Data<D>) => Effect.Effect<void, unknown>, |
| 169 | ) => |
| 170 | events.listen((event) => { |
| 171 | if (event.type !== def.type || event.location?.directory !== _ctx.directory) return Effect.void |
| 172 | return fn(event.data as EventV2.Data<D>).pipe( |
| 173 | Effect.catchCause((cause) => |
| 174 | Effect.logError("share subscriber failed", { type: def.type, cause: cause }), |
| 175 | ), |
| 176 | ) |
| 177 | }) |
| 178 | |
| 179 | yield* watch(Session.Event.Updated, (data) => |
| 180 | Effect.gen(function* () { |