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

Data: Invalidate store subscription on change in isAsync #19205

Closed
wants to merge 1 commit into from

Conversation

aduth
Copy link
Member

@aduth aduth commented Dec 17, 2019

Closes #19199
Unblocks: #19007

This pull request seeks to update the behavior of useSelect to rerun selectors when the value of the isAsync context changes. Without these changes, there can be cases such as that described in #19199 where an updated selector value will not take effect when the context value changes.

It's unclear to me whether there might be a related issue with the implementation of the priority queue where flushes should be expected to force the onStoreChange callback (see #13056 (comment)).

Testing Instructions:

Repeat steps to reproduce from #19199, verifying that each implementation of the block renders as expected.

Ensure unit tests pass:

npm run test-unit packages/data/src/components/use-select/test/index.js

@aduth aduth added [Type] Bug An existing feature does not function as intended [Package] Data /packages/data labels Dec 17, 2019
Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I haven't tested but the unit test is explicit enough.

@@ -78,7 +78,7 @@ export default function useSelect( _mapSelect, deps ) {
const mapSelect = useCallback( _mapSelect, deps );
const registry = useRegistry();
const isAsync = useAsyncMode();
const queueContext = useMemo( () => ( { queue: true } ), [ registry ] );
const queueContext = useMemo( () => ( { queue: true } ), [ registry, isAsync ] );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will make us lose previous callbacks when async mode changes.

Also see #19199 (comment).

@aduth
Copy link
Member Author

aduth commented Jan 2, 2020

If my understanding is correct based on the debugging in #19199, this is to be superseded / better resolved by a combination of #19286 and #19282.

@aduth aduth closed this Jan 2, 2020
@aduth aduth deleted the update/use-select-async-invalidate branch January 2, 2020 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Data /packages/data [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Different timing of updates between withSelect and useSelect
3 participants