Published
Edited
Jan 13, 2021
1 fork
7 stars
Insert cell
Insert cell
delay = 25
Insert cell
step_size = 50
Insert cell
counter = {
let n = 0;
while(true) {
if(delay) await Promises.delay(delay);
yield ++n;
}
}
Insert cell
// Value only changes every {step_size} steps
stepped = {
const val = Math.floor(counter / step_size) * step_size;
// If the current value hasn't changed, return a never resolving promise.
// Make sure to always return the same promise object.
return this !== val ? val : static_promise.p;
}
Insert cell
// Count how many passes we get until the cell gets reevaluated.
{
let c = 0;
while(true) yield {stepped, iterations: ++c};
}
Insert cell
// Nest the promise so it won't get resolved by the runtime
static_promise = ({p: new Promise(_=>{})})
Insert cell
Insert cell
Insert cell
Insert cell
ticks_since_load = tick_counter()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
ticks_since_minutes_invalidation = minutes, tick_counter()
Insert cell
ticks_since_hours_invalidation = hours, tick_counter()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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