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

Open
limoragni opened this Issue Jul 7, 2015 · 1 comment

Projects

None yet

2 participants

@limoragni

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.

@nilbus
Owner
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.

@nilbus nilbus added the Improvement label Jul 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment