Comparing version 0.2.7 to 0.2.8
@@ -6,3 +6,3 @@ Contributing Code to `dispatchr` | ||
[BSD license]: https://github.com/mridgway/dispatchr/blob/master/LICENSE.md | ||
[BSD license]: https://github.com/yahoo/dispatchr/blob/master/LICENSE.md | ||
[CLA]: https://yahoocla.herokuapp.com/ |
@@ -150,2 +150,5 @@ /** | ||
Dispatcher.prototype.dispatch = function dispatch(actionName, payload) { | ||
if (this.currentAction) { | ||
throw new Error('Cannot call dispatch while another dispatch is executing'); | ||
} | ||
var actionHandlers = Dispatcher.handlers[actionName] || [], | ||
@@ -152,0 +155,0 @@ defaultHandlers = Dispatcher.handlers[DEFAULT] || []; |
{ | ||
"name": "dispatchr", | ||
"version": "0.2.7", | ||
"version": "0.2.8", | ||
"description": "A Flux dispatcher for applications that run on the server and the client.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,3 +0,5 @@ | ||
# Dispatchr [![Build Status](https://travis-ci.org/yahoo/dispatchr.svg?branch=master)](https://travis-ci.org/yahoo/dispatchr) [![Dependency Status](https://david-dm.org/yahoo/dispatchr.svg)](https://david-dm.org/yahoo/dispatchr) [![Coverage Status](https://coveralls.io/repos/yahoo/dispatchr/badge.png?branch=master)](https://coveralls.io/r/yahoo/dispatchr?branch=master) | ||
# Dispatchr | ||
[![npm version](https://badge.fury.io/js/dispatchr.svg)](http://badge.fury.io/js/dispatchr) [![Build Status](https://travis-ci.org/yahoo/dispatchr.svg?branch=master)](https://travis-ci.org/yahoo/dispatchr) [![Dependency Status](https://david-dm.org/yahoo/dispatchr.svg)](https://david-dm.org/yahoo/dispatchr) [![Coverage Status](https://coveralls.io/repos/yahoo/dispatchr/badge.png?branch=master)](https://coveralls.io/r/yahoo/dispatchr?branch=master) | ||
A [Flux](http://facebook.github.io/react/docs/flux-overview.html) dispatcher for applications that run on the server and the client. | ||
@@ -32,3 +34,3 @@ | ||
### registerStore(store) | ||
### registerStore(storeClass) | ||
@@ -50,11 +52,16 @@ A static method to register stores to the Dispatcher class making them available to handle actions and be accessible through `getStore` on Dispatchr instances. | ||
### getStore(storeName) | ||
### getStore(storeClass) | ||
Retrieve a store instance by name. Allows access to stores from components or stores from other stores. | ||
Retrieve a store instance by class. Allows access to stores from components or stores from other stores. | ||
### waitFor(stores, callback) | ||
```js | ||
var store = require('./stores/MessageStore'); | ||
dispatcher.getStore(store); | ||
``` | ||
### waitFor(storeClasses, callback) | ||
Waits for another store's handler to finish before calling the callback. This is useful from within stores if they need to wait for other stores to finish first. | ||
* `stores`: A string or array of strings of store names to wait for | ||
* `storeClasses`: An array of store classes to wait for | ||
* `callback`: Called after all stores have fully handled the action | ||
@@ -80,4 +87,4 @@ | ||
* `dispatcherInterface.getContext()`: Retrieve the context object that was passed | ||
* `dispatcherInterface.getStore(store)` | ||
* `dispatcherInterface.waitFor(store[], callback)` | ||
* `dispatcherInterface.getStore(storeClass)` | ||
* `dispatcherInterface.waitFor(storeClass[], callback)` | ||
@@ -104,3 +111,3 @@ The constructor is also where the initial state of the store should be initialized. | ||
The store should define a static property that gives the name of the store. This is used for accessing stores from the dispatcher via `dispatcher.getStore(name)`. | ||
The store should define a static property that gives the name of the store. This is used internally and for debugging purposes. | ||
@@ -107,0 +114,0 @@ ```js |
@@ -31,3 +31,3 @@ /** | ||
*/ | ||
BaseStore.prototype.addChangeListener = function(callback) { | ||
BaseStore.prototype.addChangeListener = function addChangeListener(callback) { | ||
this.on(CHANGE_EVENT, callback); | ||
@@ -41,3 +41,3 @@ }; | ||
*/ | ||
BaseStore.prototype.removeChangeListener = function(callback) { | ||
BaseStore.prototype.removeChangeListener = function removeChangeListener(callback) { | ||
this.removeListener(CHANGE_EVENT, callback); | ||
@@ -49,7 +49,8 @@ }; | ||
* @method emitChange | ||
* @param {*} param=this | ||
*/ | ||
BaseStore.prototype.emitChange = function() { | ||
this.emit(CHANGE_EVENT, this.constructor); | ||
BaseStore.prototype.emitChange = function emitChange(param) { | ||
this.emit(CHANGE_EVENT, param || this); | ||
}; | ||
module.exports = BaseStore; |
@@ -60,7 +60,6 @@ /** | ||
if (spec.statics) { | ||
Object.keys(spec.statics).forEach(function (prop) { | ||
Store[prop] = spec.statics[prop]; | ||
}); | ||
} | ||
Object.keys(spec.statics).forEach(function (prop) { | ||
Store[prop] = spec.statics[prop]; | ||
}); | ||
Store.storeName = spec.storeName || Store.storeName; | ||
@@ -67,0 +66,0 @@ Store.handlers = spec.handlers || Store.handlers; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67669
430
217