-
Notifications
You must be signed in to change notification settings - Fork 11
Options
Offir Golan edited this page Jul 6, 2016
·
1 revision
Properties that will be ignored by the time machine. Supports nested keys including @each
and *
const ignoredProperties = ['someProp', 'obj.array.@each.somProp', 'obj.array.@each.*.aProp'];
const objectMachine = TimeMachine.Object.create({ content, ignoredProperties });
const arrayMachine = TimeMachine.Array.create({ content, ignoredProperties });
Properties that will not be modified. Supports nested keys including @each
and *
const content = Ember.Object.create({ array: Ember.A() });
const frozenProperties = ['someProp', 'array', 'obj.array.@each.somProp', 'obj.array.@each.*.aProp'];
const timeMachine = TimeMachine.Object.create({ content, frozenProperties });
timeMachine.set('someProp', 'foo');
timeMachine.get('someProp'); // --> undefined
timeMachine.set('someOtherProp', 'bar');
timeMachine.get('someOtherProp'); // --> 'bar'
timeMachine.get('array').pushObject('baz');
timeMachine.get('array').objectAt(0); // --> undefined
The Max nested level to track changes emitted by children of the receiver.
If set to -1
, all nested children will be tracked.
Default: -1
// Only track root level changes made by the receiver
const objectMachine = TimeMachine.Object.create({ content, maxDepth: 0 });
// Track changes up to 2 levels deep ( model.friends.firstName )
const objectMachine = TimeMachine.Object.create({ content, maxDepth: 2 });
Currently, any value of type instance
, object
, and array
(via Ember.typeOf) will automatically be wrapped in their
own Time Machine. If you don't want specific values to be wrapped, this is the place to do it.
Params:
- value ( Unknown ): The value that will be wrapped
- timeMachine ( TimeMachine ): The current Time Machine that this value belongs under
- key ( String ): The object's key that the value came from
const shouldWrapValue = (value, timeMachine, key) => {
return !(value instanceof moment) || key.indexOf('foo') !== -1;
}
const objectMachine = TimeMachine.Object.create({ content, shouldWrapValue });