Skip to content

Commit

Permalink
Add support for pure async/promise actions. Fixes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
developit committed Dec 6, 2017
1 parent 2d50049 commit e8172bb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion unistore.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ function mapActions(actions, store) {
for (let i in actions) {
mapped[i] = (...args) => {
let ret = actions[i](store.getState(), ...args);
if (ret!=null) store.setState(ret);
if (ret!=null) {
if (ret.then) ret.then(store.setState);
else store.setState(ret);
}
};
}
return mapped;
Expand Down

0 comments on commit e8172bb

Please sign in to comment.