Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think you can probably create an undo system that uses some sort of classification system for various types of undo along with a more event oriented approach. I focused on comments you made about iterating whole objects for each keystroke so will start there</p> <p>I'm assuming that you aren't updating server for every keystroke on inputs in which case you wouldn't need to watch anything other than the specific input's key events while it is in focus. When you bind CTRL +Z to the document, do it in a way that nothing global happens when an input is in focus. </p> <p>Following scenario is based on simplest UI action to track...update field only.</p> <p>On focus of an input you would immediately take a copy of it's current model value, and store that as value to use for a complete undo of the ng-model later.</p> <p>While in focus, CTRL+Z would be bound to that input and keystrokes events can be undone at very local level not impacting any need to watch at higher level. Unbind key events for that input on blur.</p> <p>On blur of an input, you would then be able to <code>$emit</code> an <code>update event</code> that you would track as category like "field update". Send the old stored value , the object that contains the <code>ng-model</code> and update category to a tracking service that listens for updates and pushes updates into an undo array.</p> <p>When user now hits undo, service looks at update type and changes the value of the object associated to the field name stored and removes that last stored item from the queue</p> <p>I did something similar to this using only jQuery for a UI that was set up to both create and manage a web page layout with absolute positioned elements throughout, as well as inserting and updating content.</p> <p>I've only started on user level input that assumes no new data objects created or deleted. Those might be handled by $.watch watching array lengths. By only watching length you wont have to iterate over every property of every object contained to figure out what changed.</p> <p>One helpful tracking property for all of this is the <code>$$hashKey</code> property that angular gives to every object it touches in all scopes. Using haskey could help map array length changes to find differences. I haven't though all of this section through a lot yet.</p> <p>Hope the event driven input tracking concept helps. At least at user input level it would cut out a significant amount of overhead using $watch</p> <p>Also angular recently added a shallower listener <code>$watchCollection</code> was added in 1.2. Haven't used it yet, but surely lightens overhead where it's use case might not warrant a full watch</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload