Created
March 27, 2015 09:52
-
-
Save ishiduca/f86ffe863eef8bfaba99 to your computer and use it in GitHub Desktop.
flux dispatcher
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
var dispatcher = module.exports = new (require('flux').Dispatcher) | |
var dispatch = dispatcher.dispatch | |
var register = dispatcher.register | |
dispatcher.dispatch = function (actionType, value) { | |
var payload = {actionType: actionType} | |
if ('undefined' !== typeof value) payload.value = value | |
return dispatch.apply(this, [payload]) | |
} | |
dispatcher.register = function (f) { | |
return register.apply(this, [function (payload) { | |
return f(payload.actionType, payload.value) | |
}]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment