@Justin_Proctor wrote:
We have many situations were we are pulling in a very large amount of data (like for a HeatMap) or data that we do not want to cache in the store. We have implemented a large number of solutions over the years but we have not found a good one that affords us a sense of ease. We are missing out on the error handling that a store call has as well as the concise amount of code. What we are looking for the proper way to use calls like
$.getJSON
that is reusable and something contained.Here is an example of a version that we have. We do not like that we need to use a property on the component to mark the promise as having errored.
weather: computed('refreshDataTrigger', function() { const that = this; let promise = new Promise(function(resolve, reject) { resolve($.getJSON(`/api/weatherForecasts/current`)); reject(); }); let promiseObject = DS.PromiseObject.create( { promise: promise }); promiseObject.then(function(value) { that.set('isErrorState', false); return value; }, function(reason) { that.set('isErrorState', true); Log.Log(reason); return null; }); return promiseObject; }),
We wanted to use this with a promise addon to handle the status of the promise like we do with normal store calls.
{{#if (is-fulfilled weather)}} {{#if (is-pending weather)}} {{#if (is-rejected weather)}}
Could we get some guidance?
Posts: 2
Participants: 2