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

Reducer helpers for optimizing updates #14

Open
andywhite37 opened this issue Aug 22, 2019 · 1 comment
Open

Reducer helpers for optimizing updates #14

andywhite37 opened this issue Aug 22, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@andywhite37
Copy link
Member

andywhite37 commented Aug 22, 2019

From a discussion with @mlms13

It might be handy to add some helper functions for filtering actions in the reducer that would result in a no-op/unnecessary Update.

One example is if your state is an AsyncData or AsyncResult, and it's currently in an Init state, and you dispatch an action that wants to map a function over your Complete(Ok(a)) value, but you're not in that state, it's better to return a NoUpdate rather than an Update that has no effect.

Example:

Update(AsyncResult.map(v => {...v, someChange}))

vs.

getOk >> fold(NoUpdate, v => Update(...))

There might be some handy helper functions for dealing with this to avoid unnecessary updates - it would be worth thinking about.

@andywhite37
Copy link
Member Author

As a side note, we should benchmark if there are any actual consequences of dispatching an Update with no state changes - it's possible react optimizes this away somehow, or it's insignificant.

@andywhite37 andywhite37 added the enhancement New feature or request label Feb 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant