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
This feature introduce history buffer to undo/redo data changes in class accessors/properties. There is 2 kind of history that can be enabled via attribute:
history=linear - use linear history where each new change after undo() will remove history of that undo()
history and autotrack=history attribute available on:
render-scope - track history on all template for each instance of all linked modules
:is(html, render-scope) > link - track history for each instance of that module
render-scope > template[shadowrootmode, define] - track history inside that template
Warning: the history will be removed/renewed when using SPA navigation #12. Cache or persist them (#14) to retain history between page navigation.
(TODO) This feature also pave a way for CRDT and data synchronization between servers and/or clients over network.
Example
<render-scopehistory=linear><linkcachehref=counter.js><linkpersisthref=naming.js><scriptlet=hstype>import*ashistoryfrom"libnusa/history"exportdefaultclass{
#index =history.branch?.length??0undo(){history.undo()}redo(){history.redo()}cycle(){history.switch(history.branch[this.#index =this.#index <history.branch.length
? this.#index +1 : 0])// maybe simplify as history.switch(-1 or +1)}}</script><templateshadowrootmode=closed><basic-example/><undotree-example/></template><templatehistory=treedefine=undotree-example><basic-example/></template><templatedefine=basic-example><button~@click=track:asyncIncrement#text=count>0</button><inputtype=textvalue="type your name!"
~.value=name@change=track+set:name><button~@click=hs.undo>↩️</button><button~@click=hs.redo>↪️</button><button~@click=hs.cycle>🔄</button></template></render-scope>
Note that each event handler need to be specified as @event=track:methods or use @history.track decorator to track the history. Specifying as @event=untrack:methods or using @history.untrack decorator will untrack the history when using autotrack=history attribute.
This feature introduce history buffer to undo/redo data changes in class accessors/properties. There is 2 kind of history that can be enabled via attribute:
history=linear
- use linear history where each new change after undo() will remove history of that undo()history=tree
- history can have branch 1history
andautotrack=history
attribute available on:render-scope
- track history on all template for each instance of all linked modules:is(html, render-scope) > link
- track history for each instance of that modulerender-scope > template[shadowrootmode, define]
- track history inside that template(TODO) This feature also pave a way for CRDT and data synchronization between servers and/or clients over network.
Example
Footnotes
see vim undo tree ↩
The text was updated successfully, but these errors were encountered: