react-model icon indicating copy to clipboard operation
react-model copied to clipboard

Need executed `setter` from `stateUpdater` communicator middleware

Open tianyingchun opened this issue 4 years ago • 0 comments

Cause of the __hash function setter has been executed in stateUpdater: Middleware

we don't need to executed this __hash state update again in communicator middleware, i think it should be changed to

 if (Global.Setter.functionSetter[modelName]) {
    Object.keys(Global.Setter.functionSetter[modelName]).map((hash) => {
      const setter = Global.Setter.functionSetter[modelName][hash];
      // If we need to exclude executed `setter` from `stateUpdater`
      // we should exclude `__hash` once __hash  has been executed in `stateUpdatater` middleware.
      if (setter && __hash !== hash) {
        if (!setter.selector) {
          setter.setState(Global.State[modelName]);
        } else {
          const newSelectorRef = setter.selector(Global.State[modelName]);
          if (!shallowEqual(newSelectorRef, setter.selectorRef)) {
            setter.selectorRef = newSelectorRef;
            setter.setState(Global.State[modelName]);
          }
        }
      }
    });
  }

tianyingchun avatar Oct 20 '20 11:10 tianyingchun