I've utilized Promises/Futures in Boost for C++ and have tried out the equivalent, Promises/Deferreds, in the Dojo Toolkit. I've looked around for something similar in Ext JS but haven't found something yet. I'm still new to Ext JS though so I could have missed it. Any pointers?
Deferreds/promises (aka. Futures) and accompanying tools help managing asynchronous logic, for example when you are waiting for two or more different stores are loaded (in the FuturesJS library this would be a Join with two or more Futures)
Another example: you want to fire some requests in a fixed sequence which must not overlap (ok, you can accomplish this with nested callbacks, but a large sequence results in a deeply nested logic). Using things like Sequence (FuturesJS library) hide this complexity and help making code with a simpler structure. Ext JS createSequence() to my knowledge doesn't work asynchronously.
We think Ext JS should provide support for this out-of-the box. It helps a lot for some complex tasks and it's hard to apply this to Ext JS by ourselves by adding external libraries and the integration is suboptimal.
I think its about how to sync multiple async-operations .
For example you've got a form with textfields and two grids in it. So you would first load the form and the two gridstores. When all three load-operations are complete you would like to do something - enable the submit button for example.
What is the best practice to accomplish this kind of task?
I guess this is a quite common problem in real-world applications...
I really agree with @s.busch here: this should really be part of the ExtJs in the nearest possible future. It's not a 'new shop', it's a technique that could simplify, prettify and optimize eventhandling between objects
As you can see, two operations take place at the same time: a web worker process is set up (asynchroneus) while a pdf File is being downloaded (asynchroneus). Both tasks need to be done, before the 'real' PDF rendering can take place. The asynchronous processes are started and monitored in another function and scope. We could set up some spaghetti Event Listener structure, but in this case there is made a promise that the processes will be executed. Without knowing how and where the promise will be forefilled, we can still be sure that some other function will only run after that has been done. This might be as a callback-like function, or straight away because the promise is already forefilled...
As you can see, two operations take place at the same time: a web worker process is set up (asynchroneus) while a pdf File is being downloaded (asynchroneus). Both tasks need to be done, before the 'real' PDF rendering can take place. The asynchronous processes are started and monitored in another function and scope. We could set up some spaghetti Event Listener structure