You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I really like the approach of "Reading from the server, and also from the cache"
The first time this module downloads (or saves) any resource, it will cache a copy of that resource in your browser. That means that the next time you try and load the resource, the $promise will immediately resolve (and, in the code snippet above, you'll see the alert with the title of the post right away). This should provide you with a nice speed boost.
The module will, however, still make a request against the server endpoint. When it receives a response, it will update the cache entry with the new values, and it will also update the value of otherPost in place. It will also trigger a $digest, so that angular can update its views if there are any that use that data. Magic! (Finally, if you need to listen specifically for the completed HTTP request, you can use the $httpPromise on the resource object instead of the regular $promise object.)
We have build several Angular apps where we grouped all interactions with REST points in "services" and we use the basic $http.get() to get data with promises.
It's not so simple to switch to the "resource" way of working to be able to plug your "angular-cached-resource" in.
Have you come across similar angular plugins that support this "Reading from the server, and also from the cache" approach but then for the basic $http?
Or is there a way that we can implement your logic in our services without converting them all to the Resource method?
The text was updated successfully, but these errors were encountered:
I really like the approach of "Reading from the server, and also from the cache"
We have build several Angular apps where we grouped all interactions with REST points in "services" and we use the basic $http.get() to get data with promises.
It's not so simple to switch to the "resource" way of working to be able to plug your "angular-cached-resource" in.
Have you come across similar angular plugins that support this "Reading from the server, and also from the cache" approach but then for the basic $http?
Or is there a way that we can implement your logic in our services without converting them all to the Resource method?
The text was updated successfully, but these errors were encountered: