Skip to content
Offir Golan edited this page Jul 6, 2016 · 1 revision

Properties

canUndo ( Boolean )

Determines if undo operations can be done

canRedo ( Boolean )

Determines if redo operations can be done

Methods

undo ( numUndos , options )

Undo the specified amount of changes that were recorded on the root machine and its children

Params:

  • numUndos ( Number ): Amount of undo operations to do. Defaults to 1
  • options ( Object ):
    • on ( Array ): Only run undo operations on the given keys
    • excludes ( Array ): Exclude undo operations on the given keys

Returns:

( Array ) All records that were undone

timeMachine.undo(); // Undo the last recorded change
timeMachine.undo(5, { on: ['firstName'] }); // Undo the last 5 changes to firstName

undoAll ( options )

Undo all changes that were recorded on the root machine and its children

Params:

  • options ( Object ):
    • on ( Array ): Run all undo operations on the given keys
    • excludes ( Array ): Exclude undo operations on the given keys

Returns:

( Array ) All records that were undone

timeMachine.undoAll();
timeMachine.undoAll({ on: ['tasks.@each.isCompleted'], excludes: ['tasks.0.isCompleted'] });

redo ( numRedos, options )

Redo the specified amount of changes that were undone on the root machine and its children

Params:

  • numRedos ( Number ): Amount of redo operations to do. Defaults to 1
  • options ( Object ):
    • on ( Array ): Only run redo operations on the given keys
    • excludes ( Array ): Exclude redo operations on the given keys

Returns:

( Array ) All records that were redone

timeMachine.redo(); // Redo the last undo operation
timeMachine.redo(5, { on: ['firstName'] }); // Redo the last 5 undo operation to firstName

redoAll ( options )

Redo all changes that were undone on the root machine and its children

Params:

  • options ( Object ):
    • on ( Array ): Run all redo operations on the given keys
    • excludes ( Array ): Exclude redo operations on the given keys

Returns:

( Array ) All records that were redone

timeMachine.redoAll();
timeMachine.redoAll({ on: ['tasks.@each.isCompleted'], excludes: ['tasks.0.isCompleted'] });

commit ( )

Clears all recorded changes and resets the state of the root machine and all its children

timeMachine.commit();

invoke ( methodName, ...args )

Invokes the named method on the receiver or on every object if the receiver is an array

Params:

  • methodName ( String ) : The name of the method
  • args ( Object... ): Optional arguments to pass

Returns:

( Unknown ) Values from calling invoke

timeMachine.invoke('save'); // === timeMachine.get('content').save();
timeMachine.invoke('set', 'foo', 'bar'); // === timeMachine.get('content').set('foo', 'bar');

printRecords ( properties )

Neatly prints all current records to console

Params:

  • properties ( Array ) : Override for which properties to be displayed
timeMachine.printRecords();
timeMachine.printRecords(['key', 'before', 'after']);