Ember Relationship Tracker is an Ember addon designed to track changes in Ember Data relationships, such as `belongsTo` and `hasMany`. It extends the functionality of Ember Data models by overwriting methods like `hasDirtyAttributes`, `changedAttributes`,
npm install ember-relationship-trackerbelongsTo and hasMany. It extends the functionality of Ember Data models by overwriting methods like hasDirtyAttributes, changedAttributes, rollbackAttributes, and save to include relationship changes.
ember install ember-relationship-tracker
`
Usage
To use the relationship tracker, extend your models from the BaseModel provided by the addon:
`
import TrackerModel from 'ember-relationship-tracker/models';
export default class MyModel extends TrackerModel {
// Your model attributes and methods here
}
`
If you want to ignore the relationship tracking, add notTracking: true
`
@belongsTo('type1', { async: false, inverse: 'type2', notTracking: true }) attrName;
`
Tracking Changes
The addon overrides the following methods to include relationship changes:
- saveInitialState: Save initialState. Note: if model is modified and saved, you may need to manually call this function yourmodel.saveInitialState()` to update initialState.