add store test and fix store

This commit is contained in:
Shin'ya Ueoka 2017-09-16 23:17:42 +09:00
parent bf75603e15
commit fb1d3b5962
2 changed files with 117 additions and 1 deletions

View file

@ -2,8 +2,12 @@ class Store {
constructor(reducer, catcher) {
this.reducer = reducer;
this.catcher = catcher;
this.state = this.reducer(undefined, {});
this.subscribers = [];
try {
this.state = this.reducer(undefined, {});
} catch (e) {
catcher(e);
}
}
dispatch(action, sender) {
@ -20,6 +24,7 @@ class Store {
this.catcher(e, sender);
}
}
return action
}
getState() {