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

Method poll

packages/effect/src/PubSub.ts:1632–1649  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1630 }
1631
1632 poll(): A | MutableList.Empty {
1633 if (this.unsubscribed) {
1634 return MutableList.Empty
1635 }
1636 this.subscriberIndex = Math.max(this.subscriberIndex, this.self.subscribersIndex)
1637 if (this.subscriberIndex !== this.self.publisherIndex) {
1638 const index = this.subscriberIndex % this.self.capacity
1639 const elem = this.self.array[index]!
1640 this.self.subscribers[index] -= 1
1641 if (this.self.subscribers[index] === 0) {
1642 this.self.array[index] = AbsentValue as unknown as A
1643 this.self.subscribersIndex += 1
1644 }
1645 this.subscriberIndex += 1
1646 return elem
1647 }
1648 return MutableList.Empty
1649 }
1650
1651 pollUpTo(n: number): Array<A> {
1652 if (this.unsubscribed) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected