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

Framework: createSelector: allow 2nd arg to be array of selectors #6391

Merged
merged 1 commit into from
Jun 29, 2016

Conversation

mcsf
Copy link
Member

@mcsf mcsf commented Jun 28, 2016

This PR allows consumers of createSelector that depend on multiple selectors to simplify their invocation of createSelector from:

createSelector(
    state => foo( state ) && bar( state ),
    state => [
        foo( state ),
        bar( state ),
        baz( state ),
    ]
);

to:

createSelector(
    state => foo( state ) && bar( state ),
    [ foo, bar, baz ]
);

To do

  • Tests
  • Doc block

Test live: https://calypso.live/?branch=add/create-selector-dependants-array

@mcsf mcsf added this to the GuidedTours M3: Multitours milestone Jun 28, 2016
@mcsf mcsf self-assigned this Jun 28, 2016
@mcsf mcsf added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels Jun 29, 2016
@mcsf mcsf force-pushed the add/create-selector-dependants-array branch from 9cb4a4d to fecd425 Compare June 29, 2016 00:41
@mcsf
Copy link
Member Author

mcsf commented Jun 29, 2016

cc @aduth for review :)

@mcsf
Copy link
Member Author

mcsf commented Jun 29, 2016

I have doubts on whether the new tests are correctly described and whether they make sense, and whether it is confusing to have these two (old and new) with such similar descriptions:

✓ should accept an array of dependent state values
✓ should accept an array of dependent selectors

@lsinger
Copy link
Contributor

lsinger commented Jun 29, 2016

In 5dc7d80 I have pushed a change to createSelector's README.md. Of course feel free to squash.

@lsinger lsinger force-pushed the add/create-selector-dependants-array branch from 5dc7d80 to 885c677 Compare June 29, 2016 10:53
@aduth
Copy link
Contributor

aduth commented Jun 29, 2016

I have doubts on whether the new tests are correctly described and whether they make sense

I think they're fine. Potentially they could be collapsed into a single test, testing both that the memoization works as intended, and that the individual selectors in the getDependants array get called with the arguments. Not sure it's a big deal enough to change.

I tweaked a few things in f25e3b5. If looks alright to you, I'm fine with merging this 👍

@mcsf
Copy link
Member Author

mcsf commented Jun 29, 2016

Awesome, thanks for your help, @lsinger and @aduth. I'll squash and merge!

Props @lsinger and @aduth for contributions!

This PR allows consumers of `createSelector` that depend on multiple
selectors to simplify their invocation of `createSelector` from:

	createSelector(
		state => foo( state ) && bar( state ),
		state => [
			foo( state ),
			bar( state ),
			baz( state ),
		]
	);

to:

	createSelector(
		state => foo( state ) && bar( state ),
		[ foo, bar, baz ]
	);
@mcsf mcsf force-pushed the add/create-selector-dependants-array branch from f25e3b5 to eb5793a Compare June 29, 2016 14:45
@mcsf mcsf merged commit 40482d3 into master Jun 29, 2016
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jun 29, 2016
@mcsf mcsf deleted the add/create-selector-dependants-array branch June 29, 2016 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants