-
Notifications
You must be signed in to change notification settings - Fork 252
Collection.parse is called 3 times #246
Comments
Is there an actual problem that this causes? |
I can only tell you what problems this has caused me - there may be others. In my parse method I transform the data that the api gives me into something that is more useful to my application. Below are a few examples of things that get converted. Specifically, the issue I ran into was when I was converting booleans. In the code below if
I have solved this by not mutating the original object but the behavior was surprising and is probably worth correcting. Maybe I can have a look if you can point me in the right direction. |
First of all, the signature of Second of all, the implementation of Lastly, |
BTW, this should be easy fix if you want to send over a PR. |
I've changed my parse methods such that they don't have side-effects I sometimes forget to do that when I'm working with an options hash or in this case with server data but yes hard lesson learned I should always make sure there are no side-effects. I'll see if I can get a PR out this week or next to shore this up. While you're right about side-effects it's quite wasteful to call a method 3 times when you only need to call it once if you can help it :) Thanks for working on this plugin - I've been using it since the original Osmani version. |
You are right! But I've never had an issue, so... besides, the fix should be pretty easy. Just need to muck with the hashes and models references a bit |
@baer would you like to send over a PR? |
Yes I would like to :) I haven't had time this week. I'm headed across the country to visit family this weekend so I'll see if I can get to it one of these evenings. If you want to get this out quickly I don't have a branch yet so if you know right where it is you won't be stepping on toes if you fix it. Up to you. |
@zeet2020 - Sorry, I never got the PR but the "fix" above is still working. |
I'm seeing parse called 3 times for paginated collections. Can't yet figure out why but it does seem to be related to
backbone.paginator
. I've verified this by using the following code.The text was updated successfully, but these errors were encountered: