Async & generator functions aren’t expanded to their values in Observable, because it’s likely that developers want to consume their outputs some other way - like with a for of loop or re-yielding their values with yield *. So calling those methods in a separate cell - as you do in this notebook - is the best way to expose the values they return, if you want to keep them as methods.
But if you don’t need them to be methods, you can use blocks instead:
animate = {
let value = 100;
let defaultTime = 40000;
let defaultDelay = 10;
let tickCounts = defaultTime/defaultDelay;
for (let i = 0; i <= tickCounts; ++i) {
await Promises.delay(defaultDelay);
yield i*value/tickCounts;
}
yield value;
}
Blocks, unlike methods, are exposed as their values, and here’s a fork that demonstrates that in this notebook. That said, they don’t take parameters like functions do, so you wouldn’t be able to customize delay and such in the same way as you’re doing now in this notebook.