Last active
August 28, 2015 03:54
-
-
Save nowri/8812ad4d0015436ec3cc to your computer and use it in GitHub Desktop.
mithrilでredux使う
This file contains 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
define(["lodash"], function(_){ | |
return { | |
bindActionsMithril: function(actions, store, m) { | |
var newActions = {}; | |
store.subscribe(function() { | |
m.endComputation(); | |
}); | |
_.each(actions, function(action, key){ | |
newActions[key] = function() { | |
var act; | |
m.startComputation(); | |
act = action.apply(this, arguments); | |
if(typeof act === "function") { | |
act(store.dispatch, store.getState); | |
} else { | |
store.dispatch(act); | |
} | |
} | |
}); | |
return newActions; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment