Live data from Hacker News

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

angular-data.pseudobry.com

11–20 of 49 posts

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

#11
post #9

From building http://platform.qbix.com/features/streams I know that there are a lot of challenges here. Caching, throttling and batching requests is of course really useful. My biggest question is how do you implement: * multi-user access * realtime updates to connected clients, and * offline editing and sync? When multiple users access a resource, you have to consider things like consistency issues (making sure all…

That actually sounds like what Firebase (https://www.firebase.com/) offers, but that's a service not a library.

You might want to have a look at http://pouchdb.com/ but I don't know how (or if) that handles consistency issues.

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

#12
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…

I agree, but it has the convenience of being able to npm install and immediately begin injecting into your app.

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

#13
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. Backbone and Ember already have these model layers but they come with heavy wrappers and getter/setter methods, and the author said he wanted to keep these as POJO objects (which Angular is loved for) without polluting them with ride-along getter/setter methods.

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

#14
"Before writing angular-data I used to create fleets of services for my various resources, each performing data management and communicating with a persistence layer."

Can someone give me an example of this? I just use $http and populte the $scope models in callbacks so I don't really recognize the problem.

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

#15
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…

Yes, I could generify it, but I'd have implement $q and $http (or introduce other dependencies), and extract angular-specific things like hooking into Angular's $digest cycle for change detection (when the browser doesn't support Object.observe).

This definitely warrants some thought. The next time I write a non-trivial application in a framework other than Angular then this will move up on my priority list. Or perhaps when the community wills it into existence :)

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

#16
post #9

From building http://platform.qbix.com/features/streams I know that there are a lot of challenges here. Caching, throttling and batching requests is of course really useful. My biggest question is how do you implement: * multi-user access * realtime updates to connected clients, and * offline editing and sync? When multiple users access a resource, you have to consider things like consistency issues (making sure all…

Multi-user access and realtime updates seem very connected to me. For these you could plug in my upcoming Firebase adapter for angular-data and boom! I actually had a complete GoInstant adapter...

Another option is too use web sockets or a pub/sub messaging service to notify all clients of changes to data, and each client can decide what it wants to do at that point (refresh data, get the changes, etc.). You could implement your own 3-way databinding this way.

Angular-data doesn't support offline editing and sync out of the box right now, but I'm considering writing an adapter that combines the existing http and localStorage adapters into one that supports offline editing and sync. Or you could make your own.

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

#17
post #14

"Before writing angular-data I used to create fleets of services for my various resources, each performing data management and communicating with a persistence layer." Can someone give me an example of this? I just use $http and populte the $scope models in callbacks so I don't really recognize the problem.

Using $http and callbacks is great to get started but it doesn't scale up to large apps very well.

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

#18
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 solution is:

https://github.com/mozilla/localForage

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

#19
post #14

"Before writing angular-data I used to create fleets of services for my various resources, each performing data management and communicating with a persistence layer." Can someone give me an example of this? I just use $http and populte the $scope models in callbacks so I don't really recognize the problem.

For those writing largish non-trivial apps its essential to separate concerns for maintainability and testability. Controllers and UI logic get separated from domain logic and your Model layer. $scope is no Model layer.
Post reply on HN