Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

Checking localStorage first before fetching from server #63

Closed
chiplay opened this issue Nov 8, 2013 · 1 comment
Closed

Checking localStorage first before fetching from server #63

chiplay opened this issue Nov 8, 2013 · 1 comment

Comments

@chiplay
Copy link

chiplay commented Nov 8, 2013

I might be missing something, but having trouble getting collections to load from localstorage. When I implement dualstorage and run fetch on a collection - the data is fetched from the remote server and saved into localstorage - as expected. But when I refresh the page, the API request is made again - instead of the data getting retrieved from localstorage. When I turn off wifi and refresh, the data is retrieved from localstorage correctly, even though it still makes a failed API request.

Is this the correct behavior for dualstorage?

@nilbus
Copy link
Owner

nilbus commented Nov 8, 2013

We've toyed around with this idea before, but at least the way it was implemented, there was a pretty decent performance penalty - see #16.

What I did to achieve the behavior you're looking for was create a local method in my collection that returns true during my initial fetch, so that I can get local data immediately if it is available, and then fetch again to pull from the remote as usual.

I'm open to ideas about how to better approach this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants