Skip to content

Instantly share code, notes, and snippets.

@odoe
Created February 8, 2016 19:14
Show Gist options
  • Select an option

  • Save odoe/89c2a483eded3db933f9 to your computer and use it in GitHub Desktop.

Select an option

Save odoe/89c2a483eded3db933f9 to your computer and use it in GitHub Desktop.
Sample Collection as a Store
define([
'esri/core/Collection',
'esri/request',
'dojo/Deferred'
], function(
Collection, esriRequest, Deferred
) {
var CameraStore = Collection.createSubclass({
apikey: null,
apiurl: null,
idProperty: 'CameraID',
loadStore: function() {
var dfd = new Deferred();
var self = this;
esriRequest({
url: this.apiurl + this.apikey,
handleAs: 'json'
}).then(function(response) {
response.map(function(x) {
x.visible = true;
self.addItem(x);
});
dfd.resolve(self);
});
return dfd.promise;
}
});
return CameraStore;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment