The interesting stuff starts when there are several serial actions (sometimes with different operations between them).
Without chaining, you will quickly find yourself writing a "Promise Soup" (all examples are in jQuery. It is pretty much the same for all other options, with slight syntax differences):
Wow. This is exactly what Promises intended to prevent in the first place!
For this simple example, chaining should be pretty straightforward:
Cool. This is much cleaner and easier to read.
Now, for a complete example (jsBin):
The really cool things here are:
- You can listen to fail/error events in one place. An error will stop the chaining and get to the closest fail statement. (jsBin)
- Resolved data will be passed to chained function.
- Passing data between "getA" to "getC" must go via "getB" (or a global object)
- Harder to implement when there are conditional calls to serial methods ("getB" is called only if some condition applies in "aData", for example)
That's it. Keep on chaining!