Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/huanghaiyang/flux-dispatcher-packer
flux dispatcher 事件监听器,用于dispatch回调
https://github.com/huanghaiyang/flux-dispatcher-packer
Last synced: 6 days ago
JSON representation
flux dispatcher 事件监听器,用于dispatch回调
- Host: GitHub
- URL: https://github.com/huanghaiyang/flux-dispatcher-packer
- Owner: huanghaiyang
- License: mit
- Created: 2016-07-28T02:02:05.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-08-02T06:54:08.000Z (over 8 years ago)
- Last Synced: 2024-10-16T08:06:01.101Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# flux-dispatcher-packer
flux dispatcher 事件监听器,用于dispatch回调# 安装
```
npm install flux-dispatcher-packer --save
```
# how to use
```javascript
const Dispatcher = require('flux-dispatcher-packer')(require('flux').Dispatcher)
``````javascript
var flightDispatcher = new Dispatcher();var CityStore = {
city: null
};flightDispatcher.register(function(payload) {
if (payload.actionType === 'city-update') {
CityStore.city = payload.selectedCity;
}
});flightDispatcher.on('afterDispatching', (payload) => {
assert.equal(CityStore.city, payload.selectedCity)
})flightDispatcher.on('afterDispatching', (payload) => {
assert.equal(CityStore.city, payload.selectedCity)
})flightDispatcher.dispatch({
actionType: 'city-update',
selectedCity: 'paris'
});flightDispatcher.unbind('afterDispatching')
assert.equal(_.isUndefined(flightDispatcher.events['afterDispatching']), true)
```