ember-cli-simple-store
Advanced tools
Comparing version 0.1.1 to 0.2.0
{ | ||
"name": "ember-cli-simple-store", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "ember-cli addon that provides a simple identity map for ember.js web applications", | ||
@@ -5,0 +5,0 @@ "directories": { |
@@ -154,6 +154,29 @@ # ember-cli-simple-store | ||
## What about the missing MyObject.save() abstraction | ||
## What about dirty tracking? | ||
Because this is a simple identity map you won't get a rich model object to inherit from that offers up save/remove/update/find. You can think of this store as the primitive in which to build something like that if and when you need it. | ||
If you want the ability to track if your model is dirty use the attr for each field and the Model base class to get save/rollback | ||
```js | ||
import { attr, Model } from "ember-cli-simple-store/model"; | ||
var Person = Model.extend({ | ||
firstName: attr(), | ||
lastName: attr(), | ||
fullName: function() { | ||
var first = this.get("firstName"); | ||
var last = this.get("lastName"); | ||
return first + " " + last; | ||
}.property("firstName", "lastName") | ||
}); | ||
//save your object to reset isDirty | ||
var person = Person.create({id: 1, firstName: 'x', lastName: 'y'}); | ||
person.set('firstName', 'toran'); | ||
person.save(); | ||
//rollback your object to reset isDirty and restore it | ||
person.set('firstName', 'foobar'); | ||
person.rollback(); | ||
``` | ||
## Running the unit tests | ||
@@ -160,0 +183,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37019
45
717
201