Ember.js, throttle REST adapter calls -
i using parse, allows 30 reqs/sec backend.
therefore, i'd throttle calls going parse via rest adapter (specifically ember-parse-adapter, extends ds.restadapter
).
i tried throttling ajax
method, assumed needed return promise:
export default parseadapter.extend({ applicationid: env.app.applicationid, restapiid: env.app.restapiid, ajax: function(url, type, options) { var self = this; return new ember.rsvp.promise(function(resolve, reject) { ember.run.later(this,resolve,5000); // prefer ember.run.throttle, not sure if work }).then(function() { return self._super(url,type,options) }); } });
however error:
typeerror: cannot read property 'results' of undefined @ exports.default.ds.default.restserializer.extend.extractarray (vendor.js:115817) @ apply (vendor.js:30197) @ superwrapper (vendor.js:29749) @ ember$data$lib$system$serializer$$default.extend.extractfindall (vendor.js:81161) @ ember$data$lib$system$serializer$$default.extend.extract (vendor.js:81144) @ superfunction [as _super] (vendor.js:25863) @ exports.default.ds.default.restserializer.extend.extract (vendor.js:115843) @ apply (vendor.js:30197) @ superwrapper [as extract] (vendor.js:29749)
what can throttle rest adapter?
if understand correctly, want batch api requests together?
i don't know best way myself, place start looking might ember cli plugin, 'ember-model-batch'
Comments
Post a Comment