Referenced in Ember Data issue #1254
I put some breakpoints in the findHasMany method for the REST serializer, and noticed that the trace was quite different on subsequent recursions.
Referenced in Ember Data issue #1254
I put some breakpoints in the findHasMany method for the REST serializer, and noticed that the trace was quite different on subsequent recursions.
| App.StorageService = Ember.Object.extend({ | |
| persistence: window.localStorage, | |
| namespace: 'ember-storage-service', | |
| init: function() { | |
| var callback = this._handleStorageEvent.bind(this); | |
| $(window).on('storage', callback); | |
| }, | |
| if (!window.localStorage) { | |
| alert("Your browser doesn't support local storage!"); | |
| } | |
| // method based approach | |
| localStorage.setItem('textSize', 'giant'); | |
| localStorage.getItem('textSize'); // => "giant" | |
| // index accessor approach | |
| localStorage['selectedTab'] = 'preferences' |
| localStorage.setItem('numbers', [1, 2, 3]); | |
| localStorage.getItem('numbers') // => "1,2,3" | |
| var hash = { hello: 'world' } | |
| localStorage.setItem('myHash', hash); | |
| localStorage.getItem('myHash') // => "[object Object]" |
| function saveItem(key, value) { | |
| var json = JSON.stringify(value); | |
| localStorage.setItem(key, json); | |
| } | |
| function loadItem(key) { | |
| var json = localStorage.getItem(key); | |
| return JSON.parse(json); | |
| } |
| App.StorageService = Ember.Object.extend({ | |
| persistence: window.localStorage, | |
| namespace: 'ember-storage-service', | |
| // ... | |
| }); |
| unknownProperty: function(key) { | |
| var namespacedKey = this._key(key); | |
| var payload = this.get('persistence').getItem(namespacedKey); | |
| return this._deserialize(payload); | |
| }, | |
| _deserialize: function(value) { | |
| return JSON.parse(value); | |
| }, |
| setUnknownProperty: function(key, value) { | |
| var namespacedKey = this._key(key); | |
| var payload = this._serialize(value); | |
| this.get('persistence').setItem(namespacedKey, payload); | |
| this.notifyPropertyChange(key); | |
| return true; | |
| }, | |
| _serialize: function(value) { | |
| return JSON.stringify(value); |
| init: function() { | |
| var callback = this._handleStorageEvent.bind(this); | |
| $(window).on('storage', callback); | |
| } | |
| _handleStorageEvent: function(event) { | |
| var storageEvent = event.originalEvent; | |
| var storageKey = storageEvent.key; | |
| var tokens = storageKey.split(':'); |