Fix up and improve RB.ResourceCollection.
Review Request #5714 — Created April 15, 2014 and submitted
RB.ResourceCollection
was documenting and supporting the old-style way
of opting in/out of resetting the collection during fetch. Backbone
changed how this worked. We now support the modern way, and document it.The modern way (Backbone.js 1.1+) is to use
reset
instead ofremove
.
Resetting is also opt-in in Backbone.js 1.1, though we flip that for
this collection to make it opt-out. We're not currently using
Backbone.js 1.1, but we want to stay close to this semantics to smooth
over the upgrade process.It's also pretty useful to be able to specify the maximum number of
items to fetch in each batch. Callers could do this by passing
extraQueryData['max-results']
, but that was less than ideal. There's now
amaxResults
option that can be passed instead.There's also fixes for the pagination indicators,
hasNext
andhasPrev
,
which could appear asundefined
depending on the payload.
Made use of this in some new code I'm working on.
Saw that I only got the number of results back that I requested when
usingmaxResults
.Saw the collection reset on each fetch, instead of just appending.
Unit tests pass.
- Change Summary:
-
Added a couple more fixes for things I hit.
- Description:
-
RB.ResourceCollection
was documenting and supporting the old-style wayof opting in/out of resetting the collection during fetch. Backbone changed how this worked. We now support the modern way, and document it. The modern way (Backbone.js 1.1+) is to use
reset
instead ofremove
.Resetting is also opt-in in Backbone.js 1.1, though we flip that for this collection to make it opt-out. We're not currently using Backbone.js 1.1, but we want to stay close to this semantics to smooth over the upgrade process. It's also pretty useful to be able to specify the maximum number of
items to fetch in each batch. Callers could do this by passing extraQueryData['max-results']
, but that was less than ideal. There's nowa maxResults
option that can be passed instead.+ + There's also fixes for the pagination indicators,
hasNext
andhasPrev
,+ which could appear as undefined
depending on the payload. - Commit:
-
b4adbfe6d15bf226853f5cf4ad322730ba1fda8074559d38e4fb2c44a94149fd98d963e1103c773e