Skip to content

Instantly share code, notes, and snippets.

@nowri
Last active August 28, 2015 03:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nowri/8812ad4d0015436ec3cc to your computer and use it in GitHub Desktop.
Save nowri/8812ad4d0015436ec3cc to your computer and use it in GitHub Desktop.
mithrilでredux使う
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