@laserware/stasis
    Preparing search index...
    • Creates channel that will subscribe to an event source using the subscribe method. Incoming events from the event source will be queued in the channel until interested takers are registered.

      To notify the channel that the event source has terminated, you can notify the provided subscriber with an END

      In the following example we create an event channel that will subscribe to a setInterval

      const countdown = (secs) => { return eventChannel(emitter => { const iv = setInterval(() => { console.log('countdown', secs) secs -= 1 if (secs > 0) { emitter(secs) } else { emitter(END) clearInterval(iv) console.log('countdown terminated') } }, 1000); return () => { clearInterval(iv) console.log('countdown cancelled') } } ) }

      Type Parameters

      • T extends NotUndefined

      Parameters

      • subscribe: Subscribe<T>

        used to subscribe to the underlying event source. The function must return an unsubscribe function to terminate the subscription.

      • Optionalbuffer: Buffer<T>

        optional Buffer object to buffer messages on this channel. If not provided, messages will not be buffered on this channel.

      Returns EventChannel<T>