Skip to content
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

Is there currently any way to intercept undo-behavior? #1135

Open
on3iro opened this issue Feb 16, 2023 · 2 comments
Open

Is there currently any way to intercept undo-behavior? #1135

on3iro opened this issue Feb 16, 2023 · 2 comments

Comments

@on3iro
Copy link
Contributor

on3iro commented Feb 16, 2023

Hey,

I am currently trying to build some kind of animation system alongside my game.
What I want to do is, declare some kind of animation state inside my game state and make each clients UI react to the animation respectively.
However this concept will somewhat clash with Undo, because the animation state will also be set to the last animation state and therefore trigger the animation again (which does not really make sense, when a move has just been undone).

First I thought of mutating the state from my react-ui and clearing the animation property whenever an undo happens, but that feels a) needlessly complicated and b) might trigger addiotional re-renders I don't want.

Now to the solution I'd prefer, but which currently seems not to be possible:
The cleanest way to achieve something like this, would be writing a plugin, which simply wraps undo.
So that when a move is being undone, we modify the state accordingly, remove the animation-declaration and set a new state, instead of the old one.

Is there already a way to build a middleware like this (the current plugin system does not seem to support such a use case) and if not would you be willing to accept PRs in that regard? Or do you have a better idea how I could solve this use case?

Thanks in advance

@walkerkd
Copy link
Contributor

Not an answer to your Undo problem … but just checking if you have discovered the bgio-effects plugin which may help you integrate your animations.

@on3iro
Copy link
Contributor Author

on3iro commented Feb 20, 2023

@walkerkd I haven't - thanks for mentioning the plugin. I will definitely have a look at it. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants