-
Notifications
You must be signed in to change notification settings - Fork 0
Iterable
Eugene Ghanizadeh edited this page Oct 21, 2021
·
5 revisions
function iterable<T>(iter: Iterable<T> | Iterator<T>): Source<T>
Emits values from given iterable (arrays, generators, etc.), when requested.
import { iterable, pipe, tap, iterate } from 'streamlets'
pipe(
iterable([1, 2, 3, 4]),
tap(console.log),
iterate
)
// > 1
// > 2
// > 3
// > 4
With observe:
import { iterable, pipe, tap, observe } from 'streamlets'
const obs = pipe(
iterable([1, 2, 3, 4]),
tap(console.log),
observe
)
obs.request()
// > 1
obs.request()
// > 2
With a generator:
import { iterable, pipe, tap, iterate } from 'streamlets'
function* gen() {
yield 1
yield 2
yield 3
}
pipe(
iterable(gen()),
tap(console.log),
iterate
)
// > 1
// > 2
// > 3