Live data from Hacker News

Angular-data: data store and caching for Angular.js

angular-data.pseudobry.com

31–40 of 49 posts

Re: Angular-data: data store and caching for Angular.js

#31
This is superb work.

Just one question, does it have the feature to add offline custom methods to the model e.g. I want to add instance calculateAge() for each User ? I couldn't find it in the guides.

Angular-RestMod provides it > https://github.com/platanus/angular-restmod#custom-methods

(basically we use node on the server and many times we just want to reuse the same server side methods on the client)

Re: Angular-data: data store and caching for Angular.js

#32

"Angular-data is very optimistic when it comes to caching. If you do DS.find('user', 5) angular-data will first look for that user in the data store. If that user is already in the data store then the promise returned by DS.find('user', 5) will immediately resolve with the user. If no user exists then (if using the http adapter) a GET request will be made, and the user returned by the server will be injected into the…

you can eject an item or collections of items from the data store with DS.eject and DS.ejectAll. Or you could load angular-cache with angular-data to activate automatic expiry of items (after a timeout or on some interval).

Re: Angular-data: data store and caching for Angular.js

#33
post #31

This is superb work. Just one question, does it have the feature to add offline custom methods to the model e.g. I want to add instance calculateAge() for each User ? I couldn't find it in the guides. Angular-RestMod provides it > https://github.com/platanus/angular-restmod#custom-methods (basically we use node on the server and many times we just want to reuse the same server side methods on the client)

You can add custom behavior to model instances via the "methods" option when defining a resource. http://angular-data.pseudobry.com/documentation/guide/angula...

Re: Angular-data: data store and caching for Angular.js

#35
post #10

Why does this has to be an angular library ? there's no need for that. You could provide a generic js library with a way to opt-in angularjs,that way,your data access layer isnt tied to a presentation framework. Can I use this lib with Backbone or React ? why this fixation on making everything depend on angular ? like jQuery in the past ? are we destined to repeat the same mistakes over and over again in the client j…

Breeze.js seems like it would be the framework agnostic version of this (I think). Its got client caching, querying, and change tracking.

http://www.breezejs.com/

Re: Angular-data: data store and caching for Angular.js

#36

"Angular-data is very optimistic when it comes to caching. If you do DS.find('user', 5) angular-data will first look for that user in the data store. If that user is already in the data store then the promise returned by DS.find('user', 5) will immediately resolve with the user. If no user exists then (if using the http adapter) a GET request will be made, and the user returned by the server will be injected into the…

I would probably make an HTTP interceptor to remove the elements from the cache on non-GET methods. The same could probably be done on socket events if you sync your clients with socket.io or something alike.

e.g.: PUT /users/123 => delete from cache the user "123"

Re: Angular-data: data store and caching for Angular.js

#37
post #10

Why does this has to be an angular library ? there's no need for that. You could provide a generic js library with a way to opt-in angularjs,that way,your data access layer isnt tied to a presentation framework. Can I use this lib with Backbone or React ? why this fixation on making everything depend on angular ? like jQuery in the past ? are we destined to repeat the same mistakes over and over again in the client j…

The "generic js library" is just your browser's localStorage. Open your browser console, type "window.localStorage['test'] = 'whatever'", refresh your browser, then type "window.localStorage.test". Did you want some library that makes it easier to add a key-value pair to an object? This is just Angular-specific boilerplate to access window/$window and add/retrieve objects without writing a bunch of low-level services…

> Plain Old Javascript Objects objects

Plan on visiting the ATM machine later?

Re: Angular-data: data store and caching for Angular.js

#38
post #10

Why does this has to be an angular library ? there's no need for that. You could provide a generic js library with a way to opt-in angularjs,that way,your data access layer isnt tied to a presentation framework. Can I use this lib with Backbone or React ? why this fixation on making everything depend on angular ? like jQuery in the past ? are we destined to repeat the same mistakes over and over again in the client j…

Breeze.js seems like it would be the framework agnostic version of this (I think). Its got client caching, querying, and change tracking. http://www.breezejs.com/

AFAIK Breeze doesn't support < IE9 which is why I can't use it for certain client projects.

Re: Angular-data: data store and caching for Angular.js

#39
This looks interesting, but I'm not sure whether it's worth tying into a complex project using angular. I have found angular already has a large learning curve for new developers, and adding another layer with its own syntax on top of it adds some complexity that I'm not necessarily convinced that is good in that situation.

It looks alright though in terms of what it offers on first inspection though. It does solve some problems that I have found myself having to solve in a similar manner with homebrewed code & structure.

Re: Angular-data: data store and caching for Angular.js

#40
post #36

"Angular-data is very optimistic when it comes to caching. If you do DS.find('user', 5) angular-data will first look for that user in the data store. If that user is already in the data store then the promise returned by DS.find('user', 5) will immediately resolve with the user. If no user exists then (if using the http adapter) a GET request will be made, and the user returned by the server will be injected into the…

I would probably make an HTTP interceptor to remove the elements from the cache on non-GET methods. The same could probably be done on socket events if you sync your clients with socket.io or something alike. e.g.: PUT /users/123 => delete from cache the user "123"

This is what I did with angular-cache.
Post reply on HN