wp-store-utils
v1.0.0
Published
Utility functions and types for working with WordPress data stores.
Readme
wp-store-utils
Utility functions and types for working with WordPress data stores.
Installation
npm install wp-store-utilsUsage
This package allows you to split a large WordPress data store into smaller, manageable, and domain-specific files using combineStoreConfigs.
import { registerStore } from '@wordpress/data';
import { combineStoreConfigs } from 'wp-store-utils';
import { featureOneConfig } from './feature-one';
import { featureTwoConfig } from './feature-two';
// Combine partial configs into one.
const finalConfig = combineStoreConfigs( featureOneConfig, featureTwoConfig );
// Register the store with WordPress.
registerStore( 'my-plugin/store', finalConfig );API
combineStoreConfigs( ...configs )
Merges multiple partial store configuration objects into one. It combines reducers, actions, selectors, and resolvers, while validating for duplicate keys.
Types
The package exports comprehensive TypeScript interfaces for WordPress data stores, including:
StoreConfigStoreActionsStoreSelectorsStoreResolvers
Contributing
Contributions to the wp-store-utils package are welcome. It is being developed in a monorepo alongside my other WordPress NPM packages. Please review the contributing guidelines to learn more about how you can contribute.
