Summary:
We are faced with the following situation with our Ember application and are trying to find a suitable solution.
We are dealing with a lot of data, and therefore some of our data requests are rather slow.
Initially, we used Em.RSVP.hash to βbindβ our queries in the hook of each route model. However, this blocks the user interface and is ultimately unacceptable.
Our solution was to cascade requests in hookController like this:
setupController: (controller, model)->
slowRequest1WhichReturnsAPromise().then (data)->
slowRequest2WhichReturnsAPromise().then (data)->
slowRequest3WhichReturnsAPromise().then (data)->
It works. We get instant page loading and can display the most relevant data first.
We try to constantly update Ember (1.11.3 at the time of writing). We are not using Ember data.
Problem:
, . , , ( ). , csrf, . , , 422.
- . ( ) . .
, "" .
:
allPromises: []
setupController: (controller, model)->
deferredRequest1 = new Em.RSVP.defer()
@get('allPromises').pushObject(deferredRequest1)
deferredRequest1.promise.then ->
deferredRequest2 = new Em.RSVP.defer()
@get('allPromises').pushObject(deferredRequest2)
actions:
signOut: ->
@get('allPromises').forEach (promise)->
promise.reject('canceled')
, .
Ember Docs , " RSVP.Promise ()". , , , .
:
promises/?
, ?
. , , , , .
.