Public
Edited
Jun 1, 2022
Insert cell
Insert cell
Insert cell
function* inf() {
for (let i = 0; true; i++) {
yield i;
}
}
Insert cell
pipe(
inf(),
rx.map((i) => i * 10)
)
Insert cell
[
...pipe(
inf(),
rx.pipe(
rx.scan((acc, i) => acc + i, 0),
rx.take(99)
)
)
]
Insert cell
range = (a, b) =>
pipe(
inf(),
rx.pipe(
rx.map((i) => i + a),
rx.take(b - a)
)
)
Insert cell
Insert cell
// implementation
function* pipe(iterable, op) {
let subscriber;
let pool = [];
new rx.Observable((s) => (subscriber = s))
.pipe(op)
.subscribe((v) => pool.push(v));

for (const value of iterable) {
subscriber.next(value);
yield* pool;
if (subscriber.closed) {
return;
}
pool = [];
}

subscriber.complete();
}
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more