You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Deprecate registry.use() and update internal implementations #11449
As per the discussion in PR #10289, a follow-up PR is needed to deprecate the registry.use() function in favor of using registerGenericStore instead to implement the functionality needed for internal wp.data plugins.
See the wp.data readme for more details on implementation.
As discussed with @coderkevin in private chat I closed initial work in #12004. He is not going to work on it until we have a clear path how to proceed further. As soon as there is an agreement on the final shape of this proposal, he is happy to reopen the PR and help to land it.
The introduction of "parent" registries (#14369) has an impact here as well, since it made for some challenges with pluggable behavior taking effect across stores (#14634). In the case of persistence, it may arguably be desirable for a behavior to only take effect on the top-level store. It could probably be implemented differently than the use pattern which exists today, though.
I'm coming around to the idea of deprecating use, but I think we still lack some equivalent to Redux's store enhancers, which it in some ways emulates.
I ended up in this issue after a long rabbit hole. registerGenericStore has now been deprecated as well. As far as I can tell, there is no alternative to enabling the persistence plugin? It appears to be de-factor deprecated, since use is (kind of) deprecated, but not really documented anywhere at all.
Essentially, the newer registration methods (createReduxStore + register) aren't supported by the persistence plugin, while registerStore now is. (But that's deprecated)
I brought this up a while ago in a separate conversation, so maybe we can continue thinking about it now!
As far as I can tell, the persistence plugin overrides the registerStore function to provide the initial state out of storage and then subscribe to persist it.
This essentially means that the persistence plugin only supports the now deprecated registration method.
Since it seems there was a lot of conversations about deprecating use completely, I'm curious what the path forward should be. I think enabling local storage persistence is worthwhile in wp data. Currently, there is not a documented, un-deprecated way to accomplish that. (The documented ways are all deprecated (but the docs haven't been updated), and while a persistence layer concept was introduced, it's only available in the preferences store.)
I think there's a documented undeprecated way of persisting data. It's the preferences package. It might require some refactoring if you're coming from the old persistence plugin (as it's not automatic) but I think it's a better approach overall.
Right, I did see that. I definitely see how it could replace persistence functionality, but it also doesn't seem like a replacement for full persistence of a redux store. But your thought would be to rewrite any data store using the persistence plugin to instead operate via global app preferences?
yes, that's my thinking. The redux store has been initially designed to be an internal implementation detail but the "use" API kind of defeated that purpose.
Another way how to make the persistence plugin compatible with the register and createReduxStore functions, is to convert it to a Redux store enhancer, and allow enhancers (and custom middlewares) to be passed as one of the options for createReduxStore.
Activity
gziolo commentedon Apr 24, 2019
As discussed with @coderkevin in private chat I closed initial work in #12004. He is not going to work on it until we have a clear path how to proceed further. As soon as there is an agreement on the final shape of this proposal, he is happy to reopen the PR and help to land it.
gziolo commentedon May 23, 2019
@youknowriad or @aduth - should we close this issue?
youknowriad commentedon May 23, 2019
I still think it should be done :) but we can discuss it.
aduth commentedon May 23, 2019
The introduction of "parent" registries (#14369) has an impact here as well, since it made for some challenges with pluggable behavior taking effect across stores (#14634). In the case of persistence, it may arguably be desirable for a behavior to only take effect on the top-level store. It could probably be implemented differently than the
usepattern which exists today, though.I'm coming around to the idea of deprecating
use, but I think we still lack some equivalent to Redux's store enhancers, which it in some ways emulates.noahtallen commentedon Mar 15, 2023
I ended up in this issue after a long rabbit hole.
registerGenericStorehas now been deprecated as well. As far as I can tell, there is no alternative to enabling the persistence plugin? It appears to be de-factor deprecated, sinceuseis (kind of) deprecated, but not really documented anywhere at all.Essentially, the newer registration methods (
createReduxStore+register) aren't supported by the persistence plugin, whileregisterStorenow is. (But that's deprecated)Looping in @talldan, @jsnajdr, and @adamziel
I brought this up a while ago in a separate conversation, so maybe we can continue thinking about it now!
As far as I can tell, the persistence plugin overrides the
registerStorefunction to provide the initial state out of storage and then subscribe to persist it.gutenberg/packages/data/src/plugins/persistence/index.js
Lines 175 to 223 in 4e343bd
This essentially means that the persistence plugin only supports the now deprecated registration method.
Since it seems there was a lot of conversations about deprecating use completely, I'm curious what the path forward should be. I think enabling local storage persistence is worthwhile in wp data. Currently, there is not a documented, un-deprecated way to accomplish that. (The documented ways are all deprecated (but the docs haven't been updated), and while a persistence layer concept was introduced, it's only available in the preferences store.)
Curious for thoughts on this :)
youknowriad commentedon Mar 15, 2023
I think there's a documented undeprecated way of persisting data. It's the preferences package. It might require some refactoring if you're coming from the old persistence plugin (as it's not automatic) but I think it's a better approach overall.
noahtallen commentedon Mar 16, 2023
Right, I did see that. I definitely see how it could replace persistence functionality, but it also doesn't seem like a replacement for full persistence of a redux store. But your thought would be to rewrite any data store using the persistence plugin to instead operate via global app preferences?
youknowriad commentedon Mar 16, 2023
yes, that's my thinking. The redux store has been initially designed to be an internal implementation detail but the "use" API kind of defeated that purpose.
jsnajdr commentedon Mar 16, 2023
Another way how to make the persistence plugin compatible with the
registerandcreateReduxStorefunctions, is to convert it to a Redux store enhancer, and allow enhancers (and custom middlewares) to be passed as one of theoptions forcreateReduxStore.