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

createSelector support multiple selectors #57

Open
gingur opened this issue Sep 28, 2018 · 3 comments
Open

createSelector support multiple selectors #57

gingur opened this issue Sep 28, 2018 · 3 comments

Comments

@gingur
Copy link

gingur commented Sep 28, 2018

Feature Request

Similar to reselect, would be nice to compose selectors with other selectors, that way the business logic can be abstracted and isolated to the selector.

Example

// basic example: state.user.avatar.src
const user = createSelector(state => state.user);
const userAvatar = createSelector(user, userState => userState.avatar);
const userAvatarSrc = createSelector(userAvatar, userAvatarState => userAvatarState.src);

// advanced example: state.user.avatar.src || state.config.defaultAvatar
const config = createSelector(state => state.config);
const defaultAvatarSrc = createSelector(config, configState => configState.defaultAvatar);
const avatar = createSelector(
  userAvatarSrc,
  defaultAvatarSrc,
  (userAvatarSrcState, defaultAvatarSrcState) => (
    userAvatarSrcState || defaultAvatarSrcState
  )
);
@seethroughdev
Copy link

It seems like createSelector is just an identity function at this point, is there consideration to just use reselect to handle memoizing?

@aweary
Copy link
Owner

aweary commented Dec 21, 2018

@seethroughtrees the idea was that createSelector would use the unstable_observedBits context API, but it's not clear if that API will ever become stable. I believe reselect already works pretty well with RCW but I'd be open to making that integration better.

@seethroughdev
Copy link

Makes perfect sense. Thanks for the great library @aweary .

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

No branches or pull requests

3 participants