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

Undo/redo pattern? #88

Closed
skosch opened this issue Jan 9, 2016 · 4 comments
Closed

Undo/redo pattern? #88

skosch opened this issue Jan 9, 2016 · 4 comments

Comments

@skosch
Copy link

skosch commented Jan 9, 2016

Hey,

mobservable looks fanstastic – it certainly promises to be much less verbose than even the most concise Redux app. Still, I often do need to support undo/redo stacks. I'm aware of @mweststrate's experiments in #9, but it seems like that didn't go anywhere. If I needed a domain data store with undo-able actions, how should I go about it?

I've come across other non-Flux approaches that try to do this, e.g. https://github.com/omniscientjs/immstruct ... might there be a way of combining those ideas?

Many thanks again for sharing this project with the community!

@mweststrate
Copy link
Member

Efficient undo / redo is very doable by tracking your state using immutable shared data structures. See for example the reactive 2015 demo which features time travelling and the createTransformer pattern that can be used to achieve patterns like these.

(another approach is to record patches, see for example these packages: https://www.npmjs.com/package/mobservable-patch-stream https://www.npmjs.com/package/observable-delta-stream or the extras.trackTransactions api, although that is mainly for debugging)

@skosch
Copy link
Author

skosch commented Jan 10, 2016

Aha, you just autorun your own serializer ... makes sense, thank you! Now I'd probably want to be able to diff two stored states so that upon undo, I can send a changeset to the server. Unfortunately the two npm packages you linked to (by @tetsuo) are dead ... any idea what happened to them?

@skosch
Copy link
Author

skosch commented Jan 11, 2016

... actually, never mind: https://github.com/chbrown/rfc6902 would do the job just fine for me.

@skosch skosch closed this as completed Jan 11, 2016
@tetsuo
Copy link
Contributor

tetsuo commented Jan 11, 2016

@skosch @mweststrate Ah, observable-delta-stream and mobservable-patch-stream are both experimental. delta stream one is very heavy, it walks the entire tree for every change, but I will definitely take a look at the latter.

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

3 participants