-
-
Notifications
You must be signed in to change notification settings - Fork 889
Correct way to use mojs with promise/async? #221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I haven't seen anything else, so I think this solution is the way to go. Mojs is not (to my knowledge) promise based at all, instead relies on callback functions. But maybe it could be a interesting feature. I personally never have needed something similar. In what use case do you need this promise to resolve? Maybe we should always return a promise when the animation is finished? |
USE CASE: I am designing a game and using frontend technology for rapid prototyping (similar to Zelda creating a 2D version for testing before implementing a full-fledged 3D version). An entity plays a burst animation once hit and only after that animation is done, the next animation shall be played (or updating the board state or stuff). I am using So instead of the code above, I can do: const burst = new mojs.Burst({
radius: {30: 120},
count: 10,
});
await burst.play().finished; |
Thanks for the use case (and interesting use of the library π). But yeah, then I can understand it's a bit easier to to sequencial code if you can use it that way. We'll look into it. |
I confirm I am using a Promise too with the |
I want to play an animation and wait until it finishes. I checked the docs and tutorials and I did not find an API that returns a promise or something.
It seems there's no related discussion here so I would like it to ask if there's a standard way of doing this?
What I am doing now is wrapping it in a promise and it works fine:
The text was updated successfully, but these errors were encountered: