forked from GeReV/Backbone.PagedCollection
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initialize empty array of models if there weren't any
- Loading branch information
Showing
1 changed file
with
7 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f13c2d1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to say this seems like a bit of an overkill.
Why perform this check on every call?
Also, I may have addressed this issue lately in my original repository, but can't remember exactly where...
f13c2d1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f13c2d1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I'm just curious, I follow your fork to get ideas.
f13c2d1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f13c2d1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite sure I understand the meaning of the drop in replacement.
But when considering caching only models, you'll have to find a way to track their position in the overall collection, since you could have missing pages.
I originally went with caching collections because it was the simplest solution I could come up with for that specific problem. Each collection is tied to its page number.
Doing that in the model-level seems to be a bit more difficult when you have to complete "holes" in the collection.
As for parameters and URL, there should be something like that in the current version of my fork, if I remember correctly.
Should be something like
data
andurl
that you can pass into fetch as options.There's something I'm trying to solve that you may be able to help with - let's say I have 2 views showing the same collection, but I want one to show 10 items and one to show, say, 8 items.
How would you change the collection so the view can dictate the per-page count?
I have it open as an issue here.
f13c2d1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"I'm not quite sure I understand the meaning of the drop in replacement."
I mean that you would be able to switch your Collection from extending Backbone.Collection to extending PagedCollection and you wouldn't have to change any other code (in my case I had to change a lot in the view).
"But when considering caching only models, you'll have to find a way to track their position in the overall collection, since you could have missing pages.
I originally went with caching collections because it was the simplest solution I could come up with for that specific problem. Each collection is tied to its page number.
Doing that in the model-level seems to be a bit more difficult when you have to complete "holes" in the collection."
I totally agree with you. I think that first-instinct for anyone here would be to cache the collections. You could still cache the collections by simply storing them in an instance variable on the PagedCollection, and, simply swapping the models from them in / out.
"As for parameters and URL, there should be something like that in the current version of my fork, if I remember correctly.
Should be something like data and url that you can pass into fetch as options."
Okay - awesome - I'll check it out. I added some of this functionality but I made it specific to my project because I just needed to get it up and running. It's pretty clear to me you are a better JS developer to me so I'm sure your fork is better =)
"There's something I'm trying to solve that you may be able to help with - let's say I have 2 views showing the same collection, but I want one to show 10 items and one to show, say, 8 items."
Okay - I'll check out your github issue.