Published
Edited
Nov 17, 2020
Insert cell
Insert cell
Insert cell
rxTimer = rx.timer(0, 1000)
Insert cell
Insert cell
rxContent = rxTimer.pipe(
rx.operators.map(val => md`This cell was reloaded ${val} seconds ago.`)
)
Insert cell
Insert cell
rx2gen(rxContent)
Insert cell
Insert cell
Insert cell
Insert cell
rxValue = gen2rx(Generators.input(viewof value))
Insert cell
Insert cell
{
var content = rxValue.pipe(
rx.operators.map(val => md`Slider value is ${val}`)
);
return rx2gen(content);
}
Insert cell
Insert cell
Insert cell
async function* agTimer() {
let i = 0;
while (true) {
await Promises.delay(1000);
yield ++i;
}
}
Insert cell
agTimer()
Insert cell
Insert cell
rx2gen(
asyncgen2rx(agTimer()).pipe(
rx.operators.map(val => md`This cell was last reloaded ${val} seconds ago`)
)
)
Insert cell
Insert cell
function rx2gen(observable) {
return Generators.observe(change => {
observable.subscribe(next => change(next));
});
}
Insert cell
function gen2rx(generator) {
return rx.Observable.create(subscriber => {
function update() {
var { done, value } = generator.next();
if (done) {
subscriber.complete();
} else {
value.then(
val => {
subscriber.next(val);
update();
},
err => {
subscriber.error(err);
}
);
}
}
update();
});
}
Insert cell
function asyncgen2rx(generator) {
return rx.Observable.create(subscriber => {
function update() {
generator.next().then(
({ done, value }) => {
if (done) {
subscriber.complete();
} else {
subscriber.next(value);
update();
}
},
err => {
subscriber.error(err);
}
);
}
update();
});
}
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more