This change adds a yewdux-utils crate with a listener that tracks the history of a state and enables undo/redo.
It works very nicely - try running new history example.
There's a couple of issues with it that I would like some feedback on.
Firstly, it should be able to initialize it by just injecting the listener using the attribute macro like this:
but the person who implemented that attribute macro (it was me!) decided to use PathList which apparently doesn't support generic types. I've asked on the Darling repo but I'm pretty sure there's no way to make that work.
So you have to initialize it the old way
impl Store for State {
fn new() -> Self {
init_listener(HistoryListener::<State>::default());
Self::default()
}
fn should_notify(&self, old: &Self) -> bool {
self != old
}
}
The other thing is that the undo tracking currently tracks a potentially infinite number of states which could lead to running out of memory quite quickly if you don't clear it periodically. I think it might be better to let you set a limit on the number of states.
https://github.com/intendednull/yewdux/issues/53#issue-1709773761
This change adds a
yewdux-utils
crate with a listener that tracks the history of a state and enables undo/redo. It works very nicely - try running new history example.There's a couple of issues with it that I would like some feedback on.
Firstly, it should be able to initialize it by just injecting the listener using the attribute macro like this:
but the person who implemented that attribute macro (it was me!) decided to use
PathList
which apparently doesn't support generic types. I've asked on theDarling
repo but I'm pretty sure there's no way to make that work. So you have to initialize it the old wayThe other thing is that the undo tracking currently tracks a potentially infinite number of states which could lead to running out of memory quite quickly if you don't clear it periodically. I think it might be better to let you set a limit on the number of states.