This repository was archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
This repository was archived by the owner on Feb 23, 2024. It is now read-only.
Interactivity API: implement the new store()
API #11065
Copy link
Copy link
Closed
Labels
type: enhancementThe issue is a request for an enhancement.The issue is a request for an enhancement.
Description
This tracking issue lists all the requirements to implement the new store()
API, which is the Interactivity API's state manager.
The whole API proposal is extensively detailed in WordPress/gutenberg#53586, and the idea is to first develop store()
here in WooCommerce Blocks and, once most of the API is tested and functioning, move all the code to Gutenberg and add proper, automated testing, documentation, etc.
This feature is being implemented in the following PR:
You can check an example of the Product Button using it in the following branch:
Tasks
- The default namespace is stored in
data-wp-interactive
- The namespace is passed as a string during store creation
- Stores return stable references to their properties
- External stores can be accessed using the same API
- Multiple parts of the same store can be defined in different files
- Objects returned by
store()
are typed - External consumers can import a typed store
- Contextual values like
context
orref
should be accessed inside the functions - Actions are just regular JavaScript functions
- Derived state (selectors) can use getters
- Derived state (selectors) can be moved back to state
- Defining the initial state in the server
- Types from the initial server state
- Accessing other namespaces in the directives
- Creating and accessing context from other namespaces in the directives
- Accessing context from other namespaces in the store
- Typing contexts
- Async Actions should use generators instead of async/await
- Stores should be able to import logic dynamically
- Stores should be able to build façades of their public APIs
- Stores should be able to define getters and functions anywhere (not only in
state
oractions
) - Element-related APIs (
getElement()
) New Interactivity `store()` API proposal WordPress/gutenberg#53586 (reply in thread) - Private stores Private store references WordPress/gutenberg#51596 (comment)
- Deep merge the raw stores instead of the proxies
Migration
- Product Button and Product Collection blocks
- Product Gallery block
Metadata
Metadata
Assignees
Labels
type: enhancementThe issue is a request for an enhancement.The issue is a request for an enhancement.