ember-cli-simple-store
Advanced tools
Comparing version 0.9.2 to 0.9.3
{ | ||
"name": "ember-cli-simple-store", | ||
"version": "0.9.2", | ||
"version": "0.9.3", | ||
"description": "ember-cli addon that provides a simple identity map for ember.js web applications", | ||
@@ -5,0 +5,0 @@ "directories": { |
@@ -86,13 +86,11 @@ # ember-cli-simple-store | ||
The full example below relies on a small xhr mixin [PromiseMixin][] | ||
The full example below relies on a small xhr addon [PromiseMixin][] | ||
```js | ||
import PromiseMixin from "js/mixins/promise"; | ||
import Ember from "ember"; | ||
import PromiseMixin from "ember-promise/mixins/promise"; | ||
var Person = Ember.Object.extend({ | ||
firstName: "", | ||
lastName: "", | ||
phone: "" | ||
}).reopenClass({ | ||
find: function(store) { | ||
var PersonRepository = Ember.Object.extend({ | ||
find: function() { | ||
var store = this.get("store"); | ||
return PromiseMixin.xhr("/api/people/", "GET").then(function(response) { | ||
@@ -105,7 +103,9 @@ response.forEach(function(person) { | ||
}, | ||
findById: function(store, id) { | ||
findById: function(id) { | ||
var store = this.get("store"); | ||
return store.find("person", id); | ||
}, | ||
insert: function(store, person) { | ||
insert: function(person) { | ||
var self = this; | ||
var store = this.get("store"); | ||
var hash = {data: JSON.stringify(person)}; | ||
@@ -127,4 +127,5 @@ return new Ember.RSVP.Promise(function(resolve,reject) { | ||
}, | ||
remove: function(store, person) { | ||
remove: function(person) { | ||
var self = this; | ||
var store = this.get("store"); | ||
var person_id = person.get("id"); | ||
@@ -143,3 +144,3 @@ var endpoint = "/api/people/%@/".fmt(person_id); | ||
export default Person; | ||
export default PersonRepository; | ||
``` | ||
@@ -159,2 +160,3 @@ | ||
var person = Person.findById(store, params.person_id); | ||
//in findByPerson you could simply filter down objects for the parent | ||
var actions = Action.findByPerson(store, params.person_id); | ||
@@ -168,2 +170,4 @@ return Ember.RSVP.hash({person: person, actions: actions}); | ||
}); | ||
export default PeoplePersonRoute; | ||
``` | ||
@@ -173,5 +177,4 @@ | ||
* additional http calls to fetch related data instead of using embedded json. You could make a single http call and parse this out if latency becomes problematic but you might find yourself managing complex object hierarchies all over again. | ||
* you will find yourself passing the store instance into model object class methods from the route/controller | ||
* you begin to use a different pattern for object materialization/filtering in the route objects because the models themselves are relationship-less. | ||
* additional http calls to fetch related data instead of using embedded json. Or you can make a single http call and parse this out if latency becomes problematic but you might find yourself managing complex object hierarchies all over again. | ||
* you will need to inject the store instance into each class that does data access (service/repository for example). | ||
@@ -238,2 +241,2 @@ I've personally found this is a great approach for apps that want to avoid the complexity of bigger projects like ember-data, but still need a single pointer /reference for the models in your ember application. | ||
[ember.js]: http://emberjs.com/ | ||
[PromiseMixin]: https://gist.github.com/toranb/98abc9616f2abecde0d4 | ||
[PromiseMixin]: https://github.com/toranb/ember-promise |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
14562002
329
179042
235