Created
February 8, 2016 19:14
-
-
Save odoe/89c2a483eded3db933f9 to your computer and use it in GitHub Desktop.
Sample Collection as a Store
This file contains hidden or 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
| 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