loopback-ds-changed-mixin
loopback-ds-changed-mixin copied to clipboard
Define callback methods on the model programatically
This is copied from #5
In a future version it would be nice the possibility of adding the logic of this mixin programatically:
/**
* var changed = {
* ids: {
* '123': 'processing',
* '456': 'processing',
* '789': 'on-hold'
* },
* values: {
* 'processing': ['123', '456'],
* 'on-hold': ['789']
* }
* }
*/
Fulfillment.onChanged('status', function(changed) {
// do first thing on changed status
});
Fulfillment.onChanged('status', function(changed) {
// do another thing on changed status
});
And even watch a specific property value:
/**
* var changed = ['123', '456'];
*/
Fulfillment.onChangedValue('status', 'cancelled', function(changed) {
// this is triggered when status changed to cancelled
});