Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Interactivity API: implement the new store() API #11065

@DAreRodz

Description

@DAreRodz

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 or ref 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 or actions)
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: enhancementThe issue is a request for an enhancement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions