MCPcopy Create free account
hub / github.com/effect-app/libs / take

Function take

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

Source from the content-addressed store, hash-verified

1158 const message = self.pollers.length === 0
1159 ? self.subscription.poll()
1160 : MutableList.Empty
1161 if (message === MutableList.Empty) {
1162 return pollForItem(self)
1163 } else {
1164 self.strategy.onPubSubEmptySpaceUnsafe(self.pubsub, self.subscribers)
1165 return Effect.succeed(message)
1166 }
1167 })
1168
1169/**
1170 * Takes all available messages from the subscription, suspending if no items
1171 * are available.
1172 *
1173 * **Example** (Taking all available messages)
1174 *
1175 * ```ts import.meta.vitest
1176 * import { Effect, PubSub } from "effect"
1177 *
1178 * const program = Effect.scoped(Effect.gen(function*() {
1179 * const pubsub = yield* PubSub.bounded<string>(10)
1180 *
1181 * const subscription = yield* PubSub.subscribe(pubsub)

Callers 1

takeRemainderLoopFunction · 0.70

Calls 5

pollForItemFunction · 0.85
takeMethod · 0.65
pollMethod · 0.65
succeedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…