WordPress Data: Registry

This entry is part 13 of 15 in the series, A Practical Overview of the @wordpress/data API

At various places so far in this series, you would have seen me use phrases like: “registered store within the current registry” “current registry dispatch” or “current registry select” I’ve also mentioned that I’d get to this mysterious “registry” reference later in the series. Well, here we are! What problem does the Registry solve? As […]

What is WordPress Data?

This entry is part 2 of 15 in the series, A Practical Overview of the @wordpress/data API

The WordPress data module (or package) is a critical component of the new WordPress Editor as demonstrated by it’s implementation in (at the time of writing) 7 other WordPress packages: @wordpress/block-directory registers a store with the core/block-directory namespace. @wordpress/block-editor registers a store with the core/block-editor namespace. @wordpress/blocks registers a store with the core/blocks namespace. @wordpress/core-data […]

WordPress Data: How to Register a Custom Store

This entry is part 3 of 15 in the series, A Practical Overview of the @wordpress/data API

The primary way in which you interact with state in wp.data is through a registered store. In this post we’re going to give an overview of the api for registering a store and then subsequent posts will dive into the specific components of the store config. registerStore( reducerKey, options ) Every data store found in […]

WordPress Data Store Properties: Resolvers

This entry is part 8 of 15 in the series, A Practical Overview of the @wordpress/data API

Before we took our side detour into learning about the controls property, I mentioned that since we now have a selector for getting products, it’d be good to implement a way to retrieve the products from the server. This is where resolvers come in. Let’s get started by creating a resolver for retrieving products. If […]

WordPress Data Store Properties: Reducer

This entry is part 10 of 15 in the series, A Practical Overview of the @wordpress/data API

In the exploration through wp.data, we’ve already created the necessary properties needed to register the custom products store for our example app. This includes, action creators, selectors, controls, and resolvers. Now it’s time to get to the last property we need for registering our store, and that’s the reducer. The reducer is arguably the most […]

WordPress Data: Putting it all together and registering your store!

This entry is part 11 of 15 in the series, A Practical Overview of the @wordpress/data API

To recap: so far in the series we’ve looked at the various properties of the configuration object for a store: selectors: which interface with the store for retrieving data from its state. actions: (actually action creators) which are used to dispatch action objects for handling by the reducer. reducer: which receives dispatched actions and determines […]

WordPress Data: Interfacing With the Store

This entry is part 12 of 15 in the series, A Practical Overview of the @wordpress/data API

Now that we have our new custom data store registered, we need to start integrating it with our example app. There are numerous ways in which you can interface with the data store in your components but I’m going to cover the four most common, straightforward ways. withSelect( mapToProps )( Component) withSelect is a higher […]