Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've implemented a mixin "Memento" which tracks changes of the properties defined in <code>mementoProperties</code> array. It supports <em>normal</em> properties as well as <em>array</em> properties.</p> <p>The basic idea is the following: when the mixin is initialized, it registers itself as observer for property changes. A property change adds a new item to the <code>memento</code> array which represents the history of changes made. Invoking <code>undo</code> sets the property to the state before the change has been made. <code>redo</code> respectively resets the value.</p> <p>The <a href="https://github.com/pangratz/ember-memento/blob/master/app/lib/memento.js" rel="noreferrer">mixin</a> is hosted on GitHub at <strong><a href="https://github.com/pangratz/ember-memento" rel="noreferrer">ember-memento</a></strong>. It can be used as follows, see <a href="http://jsfiddle.net/pangratz666/9fa95/" rel="noreferrer">http://jsfiddle.net/pangratz666/9fa95/</a>:</p> <pre class="lang-js prettyprint-override"><code>App.obj = Ember.Object.create(Ember.Memento, { name: 'hello', myArray: [], age: 12, mementoProperties: 'name age myArray'.w() }); App.obj.get('myArray').pushObject(1); App.obj.get('myArray').pushObject(2); App.obj.get('myArray').pushObject(3); App.obj.set('name', 'hubert'); App.obj.get('myArray').pushObject(4); App.obj.set('age', 190); App.obj.get('myArray').pushObjects(['a', 'b']); App.obj.undo(); // myArray = [1,2,3,4] App.obj.undo(); // age = 12 App.obj.undo(); // myArray = [1,2,3] App.obj.undo(); // name = 'hello' App.obj.redo(); // name = 'hubert' App.obj.redo(); // myArray = [1,2,3,4] App.obj.redo(); // age = 190 </code></pre>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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