Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

publishable-iterator

boschDev4MIT1.0.3

A javascript publishable async iterator lib

async, iterator, publishable

readme

publishable-iterator

A javascript publishable async iterator lib

Install

npm install --save publishable-iterator

How to use

import PublishableIterator from 'publishable-iterator'

const iterator = new PublishableIterator()

// Iterate over the PublishableIterator
for await (const item of iterator) {
  console.log(item)
}

// This will give all the active iterators a new value
iterator.publish('Hi there')

// This will give all the active iterators a new value
iterator.publish('Stop all the current itterators', true)

You can also pass an iterated type in Typescript.

interface Foo {
  bar: string
}

const iterator = new PublishableIterator<Foo>()