Mixin: DirtyModel

DirtyModel

Adds the $dirty method to a model`s instances.

Source:
  • plugins/dirty.js, line 1

Methods

$dirty(_prop) → {boolean|array}

Retrieves the model changes

Property changes are determined using the strict equality operator.

IDEA: allow changing the equality function per attribute.

If given a property name, this method will return true if property has changed or false if it has not.

Called without arguments, this method will return a list of changed property names.

Parameters:
Name Type Description
_prop string

Property to query

Source:
  • plugins/dirty.js, line 19
Returns:

Property state or array of changed properties

Type
boolean | array

$restore(_prop) → {Model}

Restores the model's last fetched values.

Usage:

bike = Bike.$create({ brand: 'Trek' });
// later on...
bike.brand = 'Giant';
bike.$restore();

console.log(bike.brand); // outputs 'Trek'
Parameters:
Name Type Description
_prop string

If provided, only _prop is restored

Source:
  • plugins/dirty.js, line 54
Returns:

self

Type
Model