new PrivateCollection(parent, guid)
- Source:
Returns a new class of collection that inherits from the parent but not the cacheMixin
and adds a requesterMixin that connects this cache to it's parent
Parameters:
Name | Type | Description |
---|---|---|
parent |
external:Backbone-Collection | the parent of the private collection |
guid |
string | the unique code of the owner of this private collection |
Extends
Members
pollTimeoutId
- Source:
- Inherited From:
- Mixes In:
Properties:
Name | Type | Description |
---|---|---|
pollTimeoutId |
number | The id from when setTimeout was called to start polling. |
Methods
addModelAndTrack(model)
- Source:
Adds a new model to the requester collection and tracks the model.id
Parameters:
Name | Type | Description |
---|---|---|
model |
external:Backbone-Model | the model to be added |
constructor(args)
- Source:
- Overrides:
- Mixes In:
Adds the loading mixin
Parameters:
Name | Type | Description |
---|---|---|
args |
Object | the arguments to the base constructor method |
createPrivateCollection(guid) → {PrivateCollection}
- Source:
- Inherited From:
- Mixes In:
Used to return a collection of desired models given the requester object.
Binds a custom "resized" event to the private collections.
Overrides the fetch method to call the parent collection's fetchByIds method.
Overrides the registerIds method to redirect to its parent collection.
Parameters:
Name | Type | Description |
---|---|---|
guid |
string | Identifier for the requesting view |
Returns:
an new empty collection of the same type as "this"
- Type
- PrivateCollection
dispose()
- Source:
- Inherited From:
Will abolish all listeners and events that are hooked
to this collection.
fetch(optionsopt) → {Promise}
- Source:
- Overrides:
Will force the cache to fetch just the registered ids of this collection
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
<optional> |
argument options Properties
|
Returns:
promise that will resolve when the fetch is complete
- Type
- Promise
fetchByIds(ids, optionsopt) → {Promise}
- Source:
- Overrides:
Will force the cache to fetch a subset of this collection's tracked ids
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
ids |
Array | array of model ids |
|
options |
Object |
<optional> |
if given, will pass the options argument to this.fetch. Note, will not affect options.idsToFetch |
Returns:
promise that will resolve when the fetch is complete
- Type
- Promise
filterDefault() → {Collection}
- Source:
- Inherited From:
The default filter. Always returns itself.
Returns:
a new instance of this collection
- Type
- Collection
getAllRequestedIds() → {Array}
- Source:
- Inherited From:
- Mixes In:
Return the list of Ids requested by this collection
Returns:
the corresponding requested Ids
- Type
- Array
getLoadedOncePromise() → {Promise}
- Source:
- Inherited From:
- Mixes In:
Returns:
a promise that will resolve when the model/collection has loaded for the first time
- Type
- Promise
getRequesterIds(the) → {Array}
- Source:
- Inherited From:
- Mixes In:
Parameters:
Name | Type | Description |
---|---|---|
the |
string | global unique id of the requester |
Returns:
an array of the ids the requester with the guid has requested
- Type
- Array
getRequesterIdsAsDictionary(guid) → {Object}
- Source:
- Inherited From:
- Mixes In:
This method is used for quick look up of a certain id within the list of requested ids
Parameters:
Name | Type | Description |
---|---|---|
guid |
string | the global unique id of the requester |
Returns:
an dictionary of id -> id of the requester ids for a given requester.
- Type
- Object
getRequesters() → {Array}
- Source:
- Inherited From:
- Mixes In:
NOTE: this methods returns only the guids for requester collections that are currently tracking ids
TODO: should this return just the knownPrivateCollections
Returns:
an array of the all requesters in the form of their GUID's
- Type
- Array
getTrackedIds() → {Array}
- Source:
Returns:
array of ids that this collection is tracking
- Type
- Array
hasLoadedOnce() → {boolean}
- Source:
- Inherited From:
- Mixes In:
Returns:
true if this model/collection has ever loaded from a fetch call
- Type
- boolean
isLoading() → {boolean}
- Source:
- Inherited From:
- Mixes In:
Returns:
true if this model/collection is currently loading new values from the server
- Type
- boolean
isPolling()
- Source:
- Inherited From:
- Mixes In:
Returns true if the poll is active
polledFetch()
- Source:
- Inherited From:
- Mixes In:
By default, the polled fetching operation is routed directly
to backbone's fetch all.
pull(optionsopt) → {Promise}
- Source:
Will force the cache to fetch any of this collection's tracked models that are not in the cache
while not fetching models that are already in the cache. Useful when you want the effeciency of
pulling models from the cache and don't need all the models to be up-to-date.
If the ids being fetched are already being fetched by the cache, then they will not be re-fetched.
The resulting promise is resolved when ALL items in the process of being fetched have completed.
The promise will resolve to a unified data property that is a combination of the completion of all of the fetches.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> |
if given, will pass the options argument to this.fetch. Note, will not affect options.idsToFetch |
Returns:
promise that will resolve when the fetch is complete with all of the data that was fetched from the server.
Will only resolve once all ids have attempted to be fetched from the server.
- Type
- Promise
registerIds(newIds, guid)
- Source:
- Inherited From:
- Mixes In:
Registers a list of Ids that a particular object cares about and pushes
any cached models its way.
This method intelligently updates the "_requestedIds" field to contain all unique
requests for Ids to be fetched. Furthermore, the "polledFetch" method
is overriden such that it no longer routes through Backbone's fetch all,
but rather a custom "fetchByIds" method.
Parameters:
Name | Type | Description |
---|---|---|
newIds |
Array | New ids to register under the requester |
guid |
string | The GUID of the object that wants the ids |
remove(modelIdentifier)
- Source:
In addition to removing the model from the collection also remove it from the list of tracked ids.
Parameters:
Name | Type | Description |
---|---|---|
modelIdentifier |
* | same duck-typing as Backbone.Collection.get(): |
removeRequester(guid)
- Source:
- Inherited From:
- Mixes In:
Removes a requester from this cache. No longer receives updates
Parameters:
Name | Type | Description |
---|---|---|
guid |
string | the global unique id of the requester |
requesterDispose()
- Source:
Handles the disposing of this collection as it relates to a requester collection.
startPolling(pollInterval)
- Source:
- Inherited From:
- Mixes In:
Starts polling Model/Collection by calling fetch every pollInterval.
Note: Each Model/Collection will only allow a singleton of polling to occur so
as not to have duplicate threads updating Model/Collection.
Parameters:
Name | Type | Description |
---|---|---|
pollInterval |
Integer | interval between each poll in ms. |
stopPolling()
- Source:
- Inherited From:
- Mixes In:
Stops polling Model and clears all Timeouts.
trackAndFetch()
- Source:
Will begin tracking the new ids and then ask the cache to fetch them
This will reset any previous list of ids being tracked.
Returns:
the promise of the fetch by ids
trackAndPull()
- Source:
Will register the new ids and then pull in any models not stored in the cache. See this.pull() for
the difference between pull and fetch.
Returns:
the promise of the fetch by ids
trackIds(ids)
- Source:
Pass a list of ids to begin tracking. This will reset any previous list of ids being tracked.
Overrides the Id registration system to route via the parent collection
Parameters:
Name | Type | Description |
---|---|---|
ids |
The list of ids that this collection wants to track |
trackNewId(id)
- Source:
Tracks a new id
Parameters:
Name | Type | Description |
---|---|---|
id |
string | Number | the id attribute of the model |