For the sake of understanding these concepts, i’m going to call the single subscriber a ‘registered callback’; and let’s call the messages emitted by the publishers, ‘payloads’.
At a glance, the registered callback may seem completely useless, since using a traditional pub/sub subscriber (via
.on method) works perfectly, but using a basic event emitter becomes problematic when modeling application into stores. The data coming in from the server is relational (the majority of the time). So for each update in a relational data store would require updates to cascade from parent dependencies. The flux dispatcher solves this issue with promises.
The flux dispatcher has method called
.waitFor. This method leverages promises to wait for each parent dispatcher to resolve before invoking the next child registered callback.
.waitFor(id) method knows the order in which to invoke each registered callback via a dispatcher token.