Skip to content
New issue

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

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

Already on GitHub? # to your account

Support for dynamic selectors #18

Open
sazzer opened this issue Jun 13, 2018 · 2 comments
Open

Support for dynamic selectors #18

sazzer opened this issue Jun 13, 2018 · 2 comments

Comments

@sazzer
Copy link

sazzer commented Jun 13, 2018

I've noticed that the Selectors are all executed immediately and the results of them are provided to the React components for rendering. This means that it's difficult to have selectors that take parameters.

What I've taken to doing, which works but feels a bit strange, is having Selectors that return functions. For example:

    selectUsers: (state) => () => selectUsers(state),
    selectUserById: (state) => (id) => selectUserById(state, id)

So the React component sees two functions, one called selectUsers with zero parameter, and one called selectUserById with a single parameter. These can then be called as needed and will return the correct values from the state, but the actual execution of them is only on-demand and they can be parameterised.

I'm not sure if such a feature would be beneficial being included as a core part of redux-box, or how, but it would be useful for me :)

@IssueHuntBot
Copy link

@BoostIO funded this issue with $50. Visit this issue on Issuehunt

@danedavid
Copy link

Can I take a shot at this?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants