Skip to content

Data: Invalidate store subscription on change in isAsync#19205

Closed
aduth wants to merge 1 commit intomasterfrom
update/use-select-async-invalidate
Closed

Data: Invalidate store subscription on change in isAsync#19205
aduth wants to merge 1 commit intomasterfrom
update/use-select-async-invalidate

Conversation

@aduth
Copy link
Copy Markdown
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
Copy Markdown
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.

const registry = useRegistry();
const isAsync = useAsyncMode();
const queueContext = useMemo( () => ( { queue: true } ), [ registry ] );
const queueContext = useMemo( () => ( { queue: true } ), [ registry, isAsync ] );
Copy link
Copy Markdown
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
Copy Markdown
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