https://github.com/workmanw/ember-did-change-attrs
https://github.com/workmanw/ember-did-change-attrs
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/workmanw/ember-did-change-attrs
- Owner: workmanw
- License: mit
- Created: 2017-10-31T18:18:48.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-09T16:14:18.000Z (over 8 years ago)
- Last Synced: 2025-03-18T14:53:46.536Z (about 1 year ago)
- Language: JavaScript
- Size: 135 KB
- Stars: 27
- Watchers: 2
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ember-did-change-attrs [](https://travis-ci.org/workmanw/ember-did-change-attrs)
This addon is a WIP rethink of [ember-diff-attrs](https://github.com/workmanw/ember-diff-attrs) which offered a decorator style approach to this problem.
With `ember-did-change-attrs` we're going to solve the same problem using mixins instead of functions. The aim is to offer a simpler API which covers attribute change use cases that previously might have been solved using the [now deprecated `didReceiveAttrs` and `didUpdateAttrs` arguments](https://github.com/emberjs/rfcs/pull/191).
This API is still experimental, suggestions for improvements are encouraged and very much appreciated.
## Installation
`ember install ember-did-change-attrs`
## Usage
```js
import DidChangeAttrs from 'ember-did-change-attrs';
export default Ember.Component.extend(DidChangeAttrs, {
didChangeAttrsConfig: {
attrs: ['email']
},
didChangeAttrs(changes) {
this._super(...arguments);
if(changes.email) {
let oldEmail = changes.email.previous,
newEmail = changes.email.current;
// Do stuff
}
}
});
```