A small utility for managing an undo stack
A small utility for managing an undo stack, that you can subscribe to in your Svelte applications (or indeed anywhere else).
…In a Svelte component, you can reference first and last as store properties without manually subscribing:
value = stack.undo()}>Undo
value = stack.redo()}>RedoYou can also access the current value of the stack, if that's preferable to tracking the value manually:
The answer is {$stack.current.answer}
Don't mutate the objects you push to the undo stack; chaos will result. Instead, create a fresh copy each time, either manually or using something like Immer.
MIT
No open issues yet, or sync has not completed.