You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 17, 2020. It is now read-only.
some implementation ideas, they might be wrong, feel free to ignore me:
don't set a limit on the history, just keep pushing, don't worry (you won't finish your memory :P)
together with state you can save an array of states
save a pointer to the current state (which normally is just statesArray.length - 1). You change it only when you hit undo or redo
When you change the state without undo and redo you need to slice the array to the current position and push on top
regarding TDD instead:
I would implement some pure functions, like saveState, undo, redo, to which you pass an array of states and return the new expected one
actually it might be useful to represent the history not only as an array but as an object with an array of states and the pointer to the current state, so you pass this object around and keep everything pure in the logic
Is that any useful?
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Think about implementing an undo function when deleting.
That's really cool by the way.
The text was updated successfully, but these errors were encountered: