(self: Subscription<A>)
| 1347 | * @since 4.0.0 |
| 1348 | */ |
| 1349 | export const take = <A>(self: Subscription<A>): Effect.Effect<A> => |
| 1350 | Effect.suspend(() => { |
| 1351 | if (self.shutdownFlag.current) { |
| 1352 | return Effect.interrupt |
| 1353 | } |
| 1354 | if (self.replayWindow.remaining > 0) { |
| 1355 | const message = self.replayWindow.take()! |
| 1356 | return Effect.succeed(message) |
| 1357 | } |
| 1358 | const message = self.pollers.length === 0 |
| 1359 | ? self.subscription.poll() |
| 1360 | : MutableList.Empty |
| 1361 | if (message === MutableList.Empty) { |
| 1362 | return pollForItem(self) |
| 1363 | } else { |
| 1364 | self.strategy.onPubSubEmptySpaceUnsafe(self.pubsub, self.subscribers) |
| 1365 | return Effect.succeed(message) |
| 1366 | } |
| 1367 | }) |
| 1368 | |
| 1369 | /** |
| 1370 | * Takes all available messages from the subscription, suspending if no items |
no test coverage detected