este-dispatcher

0.2.10 • Public • Published

este.Dispatcher Build Status Dependency Status devDependency Status

Gitter

Isomorphic Facebook Flux like dispatcher with promises support. Made with Este.js.

Features

  • Dispatcher with Promises api: All app sync/async actions and errors can be orchestrated across all app layers easily.
  • App errors can be reported via provided onError hook.
  • Isomorphic, Bower and Node.js versions included.
  • Bower version for production is super small, only 2.7 kB (gzipped). Yes, Closure Compiler.

Install

For Bower.

  bower install steida/este-dispatcher --save

For Node.js.

  npm install este-dispatcher --save

Usage

For Bower.

  // Dev
  <script src="bower_components/este-dispatcher/dispatcher.js"></script> 
  // Production
  <script src="bower_components/este-dispatcher/dispatcher.min.js"></script> 

For Node.js.

  var Dispatcher = require('este-dispatcher');

Dispatcher API

Check tests or source.

register

/**
  @param {Function} callback 
  @return {number} ID of registered callback.
*/
register(callback)

unregister

/**
  @param {number} id ID of registered callback.
*/
unregister(id)

onError

/**
  For error reporting.
  @param {string} action 
  @param {*} reason 
*/
onError(action, reason)

dispatch

/**
  @param {string} action 
  @param {Object=} payload Data for action.
  @return {!goog.Promise} 
*/
dispatch(action, payload)

waitFor

/**
  @param {Array.<number>} ids Callbacks IDs.
  @return {!goog.Promise} 
*/
waitFor(ids)

goog.Promises API

Check goog/promise/promise.js

Package Sidebar

Install

npm i este-dispatcher

Weekly Downloads

0

Version

0.2.10

License

MIT

Last publish

Collaborators

  • steida