-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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: Add ability to subscribe to one store, remove __unstableSubscribeStore #45513
Conversation
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
Size Change: -7 B (0%) Total Size: 1.32 MB
ℹ️ View Unchanged
|
Awesome, thanks a lot @jsnajdr 👍 . Code looks good to me but I will let someone with more knowledge of this codebase review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 Thanks a lot!
packages/data/src/registry.js
Outdated
return isObject( storeNameOrDescriptor ) | ||
? storeNameOrDescriptor.name | ||
: storeNameOrDescriptor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit and probably unrelated to this PR, feel free to ignore.
Maybe it'd be easier to type to check for string
instead?
return isObject( storeNameOrDescriptor ) | |
? storeNameOrDescriptor.name | |
: storeNameOrDescriptor; | |
return typeof storeNameOrDescriptor === 'string' | |
? storeNameOrDescriptor | |
: storeNameOrDescriptor.name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a good idea, implemented it 👍 One way it could backfire is when someone passes null
and then the .name
property access will crash. Previously we'd just use the null
as a key into the stores map and simply find nothing. Hope nobody really does this.
3d28d01
to
bf86777
Compare
bf86777
to
d82b371
Compare
WordPress#45513) * Add ability to subscribe to one store, remove __unstableSubscribeStore * Check typeof string in getStoreName()
As discussed in #45481, this PR is adding support for subscribing to just one store with
registry.subscribe
, via an optional second parameter.Now we can remove the
__unstableSubscribeStore
method thatuseSelect
used.useSelect
now uses only one remaining unstable internal API,__unstableMarkListeningStores
.FYI @alexflorisca who requested this 🙂