CANVE / canve-viz

CANVE visualizer UI
3 stars 1 forks source link

Introduce undo redo #14

Closed danielabar closed 8 years ago

danielabar commented 8 years ago

Starting with a simple implementation where only most recent undone action can be redone.

matanox commented 8 years ago

Tech spec suggestion draft: https://github.com/CANVE/visualizer/issues/10

matanox commented 8 years ago

Per technical research this should use the native html5 history api, which is the way back/forward is managed nowadays. Have to note the object's size limitation mentioned there on MDN (640k characters? only in firefox?) means need to consider whether to keep the graph in the object, a delta, or a pointer to a copy of a data saved elsewhere. A medium size graph took 0.5M last I checked, so 640K is a bit marginal.....

matanox commented 8 years ago

http://aurelia.io/docs.html#configuring-push-state might be probably necessary so that this plays well with Aurelia's browser history management as per its routing.

matanox commented 8 years ago

From the gitter:

Not sure what difficulty the guy faced in the interview myself.. but redux currently comes with an undo reference implementation and a "plugin" that claims to provide that implementation. The first link is an undo 101. It might be useful for only the undo/redo part; the integration into the existing framework would probably just be fetching/pushing anything that needs to be part of "redo/undo state" to redux, then binding the results as usual in Aurelia. I'll paste this in the undo/redo ticket for reference... Basically this is all more of a design pattern... but maybe something in redux makes it simpler than rolling the design pattern.

Redux architecture seems to be simple - actions only act like orders (this is called messages in other frameworks like Akka) and reducers define what actually needs to be done for each message.

Then it optionally provides workflow for asynchronous state manipulation, and middleware (which really is only useful for debug or logging, it's like node.js middleware, not that exciting..).

matanox commented 8 years ago

I'd consider the latter mainly on the merits of how much its testing best practice is inline with Aurelia's or just sensible to follow. Otherwise the quite identical design on the original ticket in the legacy repo can still be manually done.

danielabar commented 8 years ago

Javascript-undo-manager may be helpful, seems to be framework agnostic

Will need to implement "remove" versions of the functions in graph-modifier

matanox commented 8 years ago

https://github.com/ArthurClemens/Javascript-Undo-Manager looks good as well. I'd look some more on its test code but looks like it has basic testing in place.