src/promissory-arbiter.js
function publish (state, topic, data, options) {
    assert(typeof topic, 'string', 'Arbiter.publish', 'strings', 'topics');
    options = merge(state.options, options);

    var args = [state, topic, data, options];
    if (options.sync) {
      return hierarchicalTopicDispatcher(state, topic, data, options);
    }

    return async(hierarchicalTopicDispatcher, args);
  }
function publish (state, topic, data, options) {
    assert(typeof topic, 'string', 'Arbiter.publish', 'strings', 'topics');
    options = merge(state.options, options);

    var args = [state, topic, data, options];
    if (options.sync) {
      return hierarchicalTopicDispatcher(state, topic, data, options);
    }

    return async(hierarchicalTopicDispatcher, args);
  }
function publish ( state , topic , data , options ) { assert ( typeof topic , 'string' , 'Arbiter.publish' , 'strings' , 'topics' ) ; options = merge ( state . options , options ) ; var args = [ state , topic , data , options ] ; if ( options . sync ) { return hierarchicalTopicDispatcher ( state , topic , data , options ) ; } return async ( hierarchicalTopicDispatcher , args ) ; }
`Arbiter.publish` notifies all subscribers of a publication by invoking
their subscription function with the data and topic associated with the
publication.

@function publish
@memberof Arbiter

@param {Topic} topic All subscribers to this topic, will be notified of
the publication
@param {Object} [data] This data is the publication that all subscribers
will receive.
@param {Object} [options] These options override the options in
Arbiter.options for this publication only. See [`Options`](#options) for
a complete list
@return {PublicationPromise} This resolves according to
[`Options`](#options)

@example

var options = {persist: true, preventBubble: true};
Arbiter.publish('app.init', 'initialization', options);
Arbiter.subscribe('app', log); // => Nothing because of `preventBubble`
Arbiter.subscribe('app.init', log); // => logs app.init initialization
 
`publish` returns a `PublicationPromise`. This is a regular old
promise with some additional properties described below. Each property is
updated in real time as updates occur; it stops updating when the promise
fulfills. This can be changed with
`Arbiter.options.updateAfterSettlement`.

@typedef PublicationPromise PublicationPromise
@memberof Arbiter
@property {number} fulfilled The number of promises fulfilled when this
promise settles.
@property {number} rejected The number of promises rejected when this
promise settles.
@property {number} pending The number of promises pending when this
promise settles.
@property {Token} token If the `options.persist` is true, then a token is
added to the promise so it can be removed later.

@example

Arbiter.subscribe('get', getFromCache);
Arbiter.subscribe('get', getFromAjax);
Arbiter.publish('get', {latch: 1})
.then(function(data) {
// This is fulfilled when one of the subscribers fulfills because
// of `latch: 1`. In this case we could also use `latch: 0.5`.
}, function(errs) {
// This occurs when it is impossible to satisify the latch. In this
// case, both have to fail.
});
Arbiter . publish notifies all subscribers of a publication by invoking their subscription function with the data and topic associated with the publication .