Collection Store

The collection store is created to store collections in memory on the client-side. This will reduce the number of requests to the API by saving the results from the first API request. The Collection Store also populates the Model Store by adding each of the collection's models to it. Generally, this does not need to be modified, and it is instantiated by the app during the app initialization.

The Collection Store is attached to the Fetcher class, so when you make a request through the fetcher it will check the store before continuing the request.

cache CollectionStore.cache


An object of collections that stores data in memory to reduce the number of round trips to the API. Overriding data or modifying the cache is not recommended, but it is helpful for inspecting the data.

clear CollectionStore.clear([collectionName], [params])


Removes the collection from the cache. Passing both parameters will clear a specific collection that matches the collectionName and params. Passing only the collectionName will clear all instances of that collection. Passing no parameters will clear all collections from the store.

expireSeconds CollectionStore.expireSeconds


The length of time that the collection will be stored, in seconds. By default this is set to null, so the data will not expire until the page is reloaded.

get CollectionStore.get(collectionName, params, [callback])


Returns the collection from the store based on the collection name and its params.

You can also use the get function asynchronously by passing a callback function.

// async
fetcher.collectionStore.get('UsersCollection', { ids: [1,2,3] }, function (result) {
  // do something with the users
});

// sync
var result = fetcher.collectionStore.get('UsersCollection', { ids: [1,2,3] })

set CollectionStore.set(collection, params)


Adds the collection to the cache. The params for the collection are used as part of a unique identifier for the collection.