Fantasy about async/await #941
Replies: 2 comments
-
In general, the idea with async/await is not so bad. Without animation, but with the general concept of working with frames. |
Beta Was this translation helpful? Give feedback.
-
Generators work better with animation because you can explicitly progress them each frame by calling With This is how you can implement your example in Motion Canvas right now: const tasks = [];
yield dot().x(-800).x(800, 5);
while (dot().x.context.isTweening()) {
const point = (
<Circle position={dot().position()} size={5} fill={'white'} />
);
view.add(point);
tasks.push(yield delay(5, point.opacity(0, 3)));
yield;
}
yield* join(...tasks); But it highlights a missing piece in our implementation, namely the const tasks = [];
yield* tween(5, value => {
dot().x(map(-800, 800, value));
const point = (
<Circle position={dot().position()} size={5} fill={'white'} />
);
view.add(point);
tasks.push(spawn(delay(5, point.opacity(0, 3))));
});
yield* join(...tasks);
The core of Motion Canvas is generator-independent. If you can implement the |
Beta Was this translation helpful? Give feedback.
-
Guys, I played around for a couple of days. Amazing work done, and there were probably reasons for the decisions made that ultimately led to where we are. But it’s strange for me to work with generators, since I’ve long been accustomed to asynchronous functions.
I've jotted down code for an ideal approach that I'd be happy with. This of course does not mean that you need to rebuild the entire project from scratch. And it doesn’t mean that I will adapt or develop my own engine. But it would be cool if something like that could be done.
I understand how to implement everything that I wrote in async/await on generators, the same ones that are used now. Except for the case that I `marked' in the code. With dynamic addition of view points and removal of them after a short animation.
If suddenly someone shows how to implement this piece of code using generators, that would be great!
But in general, just what do you think about if motion canvas allowed you to write such code?
Beta Was this translation helpful? Give feedback.
All reactions