Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need executed setter from stateUpdater communicator middleware #166

Open
tianyingchun opened this issue Oct 20, 2020 · 0 comments
Open

Need executed setter from stateUpdater communicator middleware #166

tianyingchun opened this issue Oct 20, 2020 · 0 comments
Assignees

Comments

@tianyingchun
Copy link

tianyingchun commented Oct 20, 2020

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]);
          }
        }
      }
    });
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants