-
Notifications
You must be signed in to change notification settings - Fork 22
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
Consider using wp.data
layer instead of custom event dispatch
#50
Comments
hi @mcsf, thanks for your input. I haven't worked with the data layer before. Can you give an example how you would see this? Would it work like a wrapper function to handle the consent state? |
Sure! Consulting the Consent API would look like: wp.data.select( 'core/consent' ).hasConsent( category )
-> true where wp.data.select( 'core/block-editor' ).getBlocks()
-> [ { ... }, { ... } ]
wp.data.select( 'core/block-editor' ).getBlockCount()
-> 2 For actions representing state changes and other effects, you would have: wp.data.dispatch( 'core/consent' ).setConsent( category, value )
For the consumer, the wrappers would be the selectors and action-dispatchers as seen above. For the implementer, you'd register the Consent store by providing these selectors and actions and, most importantly, the reducer, which is the internal mediator of state and actions. The store for |
@mcsf thanks for your input on this. I've given it some thought, and don't think the datalayer would be an appropriate solution for the consent levels. I think it's very important that end users can see where their consent is stored (and for how long) in the most simple way possible, which is most transparant and publicly known with cookies. Additionally, it looks like the expiration period of the data can't be set. The expiration is something that explicitly needs to be adjustable, depending on the configuration of the cookie banner plugin that fires the consent. Please let me know what you think @phpgeek, @mrxkon, @mundschenk-at |
Hi @mcsf @rlankhorst ! As one of the people who helps maintain parts of the data module, I thought I'd drop in and share a few of my own thoughts. First, I think this sort of discussion would make for an excellent topic in one of the weekly #core-js weekly JavaScript chats. I'd be happy to help coordinate for this to be on the agenda for an upcoming meeting if there's an interest. To clarify a point about the data module: The data module isn't particularly opinionated about data storage. In fact, even the "default" persistence mechanism is implemented as a plugin that WordPress opts-in to. Furthermore, while it does use Where the data module is more opinionated, and which I think could still apply here, is in providing a consistent public interface for accessing, mutating, and subscribing to changes in state. What I see in the documentation with To the point about expiration, while this could be implemented today as an extension of the data module, I think it's also worth highlighting that the feature-set of the module isn't set in stone and can be improved upon to better support these sorts of use-cases. Enhancements driven by real-world requirements like those outlined here could go a long way to help improve its utility for the benefit of all usage. |
Thanks @aduth I'd be happy to join that chat if you can coordinate. |
@garretthyder Great! I added it to the agenda for tomorrow's chat at 14:00 UTC. If that's too soon and there's nobody who can attend, we can punt it to next week's meeting. I added some rough notes based on my understanding of the needs, but feel free to suggest (in the document) any revisions, or bring them up during the chat. |
Awesome thanks @aduth, agenda looks good and I'll try to wake up that early. |
Following on a discussion in slack #core-js this seems like a very valid idea. @rlankhorst let's discuss further if you're around Wednesday for our #core-privacy chat at 19:00 UTC. |
I'll dive into this and will try go get a branch setup for this. |
Interesting discussion. My initial reaction was that the consent API primarily operates on the client side for site visitors. What is the overhead / impact of making I'm definitely not saying it isn't still worth considering, especially if there are other client side uses for |
Hello.
Given the heavy investment in WordPress's
data
module, especially in the context of the development of the Block Editor, has it been considered for supporting for the Consent API's client-side interface?Stores under
wp.data
supportsubscribe
,select
anddispatch
. There are a couple of benefits to it, from useful deprecation mechanisms for backwards compatibility, to the fact that consumers of the API may choose to consume it via a traditional "subscribe and dispatch" design, or declaratively from withinwp.element
-powered UIs (cf.useSelect
). There are also affordances in place for client-side persistence of preferences.Of course, the drawback to consider is the addition of dependencies.
I'm interesting in hearing how you weigh this approach against the current event-based one.
The text was updated successfully, but these errors were encountered: