goodeggs / angular-cached-resource

An AngularJS module to interact with RESTful resources, even when browser is offline
MIT License
216 stars 29 forks source link

define CachedResource::toJSON to prevent storing and to localStorage #65

Closed makebbekus closed 9 years ago

makebbekus commented 9 years ago

We encountered a bug where an instance of a CachedResource that was instantiated from reading out of the cache had $promise and $httpPromise properties that were later getting serialized to localStorage. In an offline scenario, reading from the cache would then return an empty object because the real deferred objects would get blown away by the improperly serialized promises.

This PR omits these properties before writing to them to localStorage.

hazeledmands commented 9 years ago

LGTM :clap: