Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing the string of ids for a collection each time a model updates blocks the main process #143

limoragni opened this issue Jul 7, 2015 · 1 comment


Copy link

limoragni commented Jul 7, 2015

I have a fairly big database with a table containing near 9K rows. When I fetch the collection the request takes about 8 seconds but the localsync methods takes a lot more and blocks the application.

After some debugging I found that the problem is that for each model it does the following:

  • Reads the strings containing all the ids and parse it to an Array
  • Pushes the id to the array
  • Saves the array to a string and writes de corresponding model to localStorage

This is inefficient. I think the Collection should keep track of what models were stored in an array, and after all the models are stored it should write the string with all the models ids.

And the fetch method that triggers this behaviour should return a promise that resolves when all the models are stored.

Copy link

nilbus commented Jul 10, 2015

I welcome patches that improve the efficiency! If you're up to it, feel free to ask me any questions you have along the way.

Be aware of the async branch, which will be 2.0 when someone gets around to testing it and working out any issues. :-) That branch does return promises for everything. If that's what you need, you may want to experiment with using that branch. It has been so long since I have been able to work on it, I can't remember what was blocking its release. I think the test suite should tell you though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants