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

Objects

Setup

import TimeMachine from 'ember-time-machine';

const content = Ember.Object.create({
  firstName: 'Offir'
});

const timeMachine = TimeMachine.Object.create({ content });

Manipulate

timeMachine.get('firstName'); // --> 'Offir'
timeMachine.set('lastName', 'Golan');

Undo & Redo

timeMachine.get('lastName'); // --> 'Golan'
timeMachine.undo();
timeMachine.get('lastName'); // --> undefined
timeMachine.redo();
timeMachine.get('lastName'); // --> 'Golan'

Arrays

Setup

import TimeMachine from 'ember-time-machine';

const timeMachine = TimeMachine.Array.create({ content: Ember.A([ 'offir' ]) });

Manipulate

timeMachine.get('firstObject'); // --> 'Offir'
timeMachine.pushObject('Golan');

Undo & Redo

timeMachine.objectAt(1); // --> 'Golan'
timeMachine.undo();
timeMachine.objectAt(1); // --> undefined
timeMachine.redo();
timeMachine.objectAt(1); // --> 'Golan'