Comparing version 0.1.1 to 0.2.0
@@ -5,2 +5,2 @@ /** | ||
*/ | ||
module.exports = require('./lib/dispatcher'); | ||
module.exports = require('./lib/Dispatcher'); |
{ | ||
"name": "dispatchr", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "A Flux dispatcher for applications that run on the server and the client.", | ||
@@ -23,5 +23,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"debug": "^1.0.0", | ||
"es6-promise": "^1.0.0", | ||
"setimmediate": "^1.0.2" | ||
"debug": "^1.0.0" | ||
}, | ||
@@ -28,0 +26,0 @@ "devDependencies": { |
@@ -18,5 +18,4 @@ # 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) | ||
dispatcher.dispatch('NAVIGATE', {}, function (err) { | ||
// Action has been handled fully | ||
}); | ||
dispatcher.dispatch('NAVIGATE', {}); | ||
// Action has been handled fully | ||
``` | ||
@@ -36,3 +35,3 @@ | ||
### dispatch(actionName, payload, callback) | ||
### dispatch(actionName, payload) | ||
@@ -43,3 +42,2 @@ Dispatches an action, in turn calling all stores that have registered to handle this action. | ||
* `payload`: An object containing action information. | ||
* `callback`: A function that will be called when the action has been fully handled by all stores | ||
@@ -57,3 +55,3 @@ ### getStore(storeName) | ||
### toJSON() | ||
### dehydrate() | ||
@@ -64,3 +62,3 @@ Returns a serializable object containing the state of the Dispatchr instance as well as all stores that have been used since instantiation. This is useful for serializing the state of the application to send it to the client. | ||
Takes an object representing the state of the Dispatchr instance (usually retrieved from toJSON) to rehydrate the instance as well as the store instance state. | ||
Takes an object representing the state of the Dispatchr instance (usually retrieved from dehydrate) to rehydrate the instance as well as the store instance state. | ||
@@ -73,14 +71,17 @@ ## Store Interface | ||
The store should have a constructor function that will be used to instantiate your store using `new Store(context, initialState)` where the parameters are as follows: | ||
The store should have a constructor function that will be used to instantiate your store using `new Store(dispatcherInterface)` where the parameters are as follows: | ||
* `context`: The context object that was passed to Dispatchr's constructor. | ||
* `initialState`: The initialState of the store (generally used during rehydration) | ||
* `dispatcherInterface`: An object providing access to dispatcher's waitFor and getStore functions | ||
* `dispatcherInterface.getContext()`: Retrieve the context object that was passed | ||
* `dispatcherInterface.getStore(store)` | ||
* `dispatcherInterface.waitFor(store[], callback)` | ||
```js | ||
function ExampleStore(context, initialState) { | ||
this.navigating = false; | ||
function ExampleStore(dispatcher) { | ||
this.dispatcher = dispatcher; | ||
this.getInitialState(); | ||
} | ||
``` | ||
It is also recommended to extend an event emitter so that your store can emit `update` events to the components. | ||
It is also recommended to extend an event emitter so that your store can emit `change` events to the components. | ||
@@ -113,9 +114,7 @@ ```js | ||
* `payload`: An object containing action information. | ||
* `done`: A function to be called when the action has been fully handled by the store | ||
```js | ||
ExampleStore.prototype.handleNavigate = function (payload, done) { | ||
ExampleStore.prototype.handleNavigate = function (payload) { | ||
this.navigating = true; | ||
this.emit('update'); // Component may be listening for updates to state | ||
done(); // Action has been fully handled | ||
this.emit('change'); // Component may be listening for changes to state | ||
}; | ||
@@ -136,16 +135,10 @@ ``` | ||
### setDispatcher(dispatcher) | ||
### dehydrate() | ||
The store can optionally define this function that will receive the Dispatchr instance after instantiation of the store. This gives the store access to functions like `waitFor` and `getStore` to call other stores. | ||
The store can optionally define this function to customize the dehydration of the store. It should return a serializable data object that will be passed to the client. | ||
```js | ||
ExampleStore.prototype.setDispatcher = function (dispatcher) { | ||
this.dispatcher = dispatcher; | ||
}; | ||
``` | ||
### rehydrate(state) | ||
### toJSON() | ||
The store can optionally define this function to customize the rehydration of the store. It should restore the store to the original state using the passed `state`. | ||
The store can optionally define this function to customize the dehydration of the store. It should return a serializable data object that will be passed to the client. | ||
## License | ||
@@ -152,0 +145,0 @@ |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
47734
1
19
294
142
1
- Removedes6-promise@^1.0.0
- Removedsetimmediate@^1.0.2
- Removedes6-promise@1.0.0(transitive)
- Removedsetimmediate@1.0.5(transitive)