register(function callback): string
Registers a callback to be invoked with every dispatched payload. Returns a token that can be used with waitFor().

unregister(string id): void
Removes a callback based on its token.

waitFor(array<string> ids): void
Waits for the callbacks specified to be invoked before continuing execution of the current callback. This method should only be used by a callback in response to a dispatched payload.

dispatch(object payload): void Dispatches a payload to all registered callbacks.

For example, consider this hypothetical flight destination form, which
selects a default city when a country is selected:

var flightDispatcher =newDispatcher();
// Keeps track of which country is selected
var CountryStore ={country:null};
// Keeps track of which city is selected
var CityStore ={city:null};
// Keeps track of the base flight price of the selected city
var FlightPriceStore ={price:null};

When the callback to update CountryStore is registered, we save a reference
to the returned token. Using this token with waitFor(), we can guarantee
that CountryStore is updated before the callback that updates CityStore
needs to query its data.

CityStore.dispatchToken = flightDispatcher.register(function(payload){if(payload.actionType ==='country-update'){ // `CountryStore.country` may not be updated.
flightDispatcher.waitFor([CountryStore.dispatchToken]); // `CountryStore.country` is now guaranteed to be updated.
// Select the default city for the new country
CityStore.city =getDefaultCityForCountry(CountryStore.country);}});