jhonnymichel / react-hookstore

A state management library for react using the bleeding edge hooks feature

Home Page:https://codesandbox.io/s/r58pqonkop

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

would be nice to have a callback()

medyll opened this issue · comments

something like dispatch({},func) , as in setState

Cool ideia. I want to have it implemented! If you'd like to contribute feel free to do so! :) If you don't feel like it, that's fine, I can work on it this week.

I would do something like :

var store = {
    state: state,
    reducer: reducer,
    setState: function setState(action,callback) {
      var _this = this;

      this.state = this.reducer(this.state, action);
      this.setters.forEach(function (setter) {
        return setter(_this.state);
      });
      if(callback) callback(this.state)
    },
    setters: []
  };

and yes, i feel to contribute, will be on it on the next day

Implemented on #9