Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-cli-simple-store

Package Overview
Dependencies
Maintainers
2
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-cli-simple-store - npm Package Compare versions

Comparing version 0.9.2 to 0.9.3

tmp/babel-tmp_cache_dir-inwlL6C1.tmp/0

2

package.json
{
"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
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc