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

Improve useStore's performance on huge dataset #46

Open
ArrayZoneYour opened this issue Feb 17, 2019 · 0 comments
Open

Improve useStore's performance on huge dataset #46

ArrayZoneYour opened this issue Feb 17, 2019 · 0 comments
Assignees

Comments

@ArrayZoneYour
Copy link
Contributor

ArrayZoneYour commented Feb 17, 2019

Every useStore create a setState now. The cost of communicator middleware will be expensive when the new state passed in setState is huge and the number of components(use useStore hooks) is big.

Enhance:

// before
const useStore = (modelName: string, depActions?: string[]) => {
  const [, setState] = useState(Global.State[modelName].state)
  // ...
}

// expected
const useStore = (modelName: string, depActions?: string[]) => {
  // If Context exist
  const { [modelName]: { setState } } = useContext(GlobalContext)
  // If not
  const [, setState] = useState(Global.State[modelName].state)
  // ...
}
@ArrayZoneYour ArrayZoneYour added the ✨Feature Request New feature or request label Feb 17, 2019
@ArrayZoneYour ArrayZoneYour self-assigned this Feb 17, 2019
@ArrayZoneYour ArrayZoneYour added 🚀performance and removed ✨Feature Request New feature or request labels Feb 17, 2019
@ArrayZoneYour ArrayZoneYour changed the title useStore's actions/state should use single truth directly Improve useStore's performance on huge dataset Feb 17, 2019
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

1 participant