MCPcopy Create free account
hub / github.com/Effect-TS/effect / unsubscribe

Function unsubscribe

packages/effect/src/PubSub.ts:1090–1111  ·  view source on GitHub ↗
(self: Subscription<A>)

Source from the content-addressed store, hash-verified

1088 )
1089
1090const unsubscribe = <A>(self: Subscription<A>): Effect.Effect<void> =>
1091 Effect.uninterruptible(
1092 Effect.withFiber<void>((state) => {
1093 MutableRef.set(self.shutdownFlag, true)
1094 return Effect.forEach(
1095 MutableList.takeAll(self.pollers),
1096 (d) => Deferred.interruptWith(d, state.id),
1097 { discard: true, concurrency: "unbounded" }
1098 ).pipe(
1099 Effect.tap(() =>
1100 Effect.sync(() => {
1101 self.subscribers.delete(self.subscription)
1102 self.subscription.unsubscribe()
1103 self.replayWindow.close()
1104 self.strategy.onPubSubEmptySpaceUnsafe(self.pubsub, self.subscribers)
1105 })
1106 ),
1107 Effect.when(self.shutdownHook.open),
1108 Effect.asVoid
1109 )
1110 })
1111 )
1112
1113/**
1114 * Takes a single message from the subscription. If no messages are available,

Callers 3

Atom.test.tsFile · 0.85
subscribeFunction · 0.85
dehydrateFunction · 0.85

Calls 9

whenMethod · 0.80
setMethod · 0.65
pipeMethod · 0.65
forEachMethod · 0.65
takeAllMethod · 0.65
unsubscribeMethod · 0.65
closeMethod · 0.65
syncMethod · 0.45

Tested by

no test coverage detected