How to use the @wordpress/data.registerStore function in @wordpress/data

To help you get started, we’ve selected a few @wordpress/data examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github WordPress / gutenberg / packages / viewport / src / store / index.js View on Github external
/**
 * WordPress dependencies
 */
import { registerStore } from '@wordpress/data';

/**
 * Internal dependencies
 */
import reducer from './reducer';
import * as actions from './actions';
import * as selectors from './selectors';

export default registerStore( 'core/viewport', {
	reducer,
	actions,
	selectors,
} );
github Automattic / wp-calypso / packages / data-stores / src / verticals-templates / index.ts View on Github external
export function register(): typeof STORE_KEY {
	if ( ! isRegistered ) {
		isRegistered = true;
		registerStore< State >( STORE_KEY, {
			actions,
			controls,
			reducer,
			resolvers,
			selectors,
		} );
	}
	return STORE_KEY;
}
github LearnPress / learnpress / assets / src / js / frontend / modal / store / index.js View on Github external
import { registerStore } from '@wordpress/data';

import reducer from './reducer';
import * as actions from './actions';
import * as selectors from './selectors';
import applyMiddlewares from './middlewares';

const { controls: dataControls } = LP.dataControls;

const store = registerStore( 'learnpress/modal', {
	reducer,
	selectors,
	actions,
	controls: {
		...dataControls,
	},
} );

applyMiddlewares( store );

export default store;
github WordPress / gutenberg / editor / store / index.js View on Github external
/**
 * Internal dependencies
 */
import reducer from './reducer';
import applyMiddlewares from './middlewares';
import * as selectors from './selectors';
import * as actions from './actions';
import * as tokens from '../components/rich-text/core-tokens';
import { validateTokenSettings } from '../components/rich-text/tokens';

/**
 * Module Constants
 */
const MODULE_KEY = 'core/editor';

const store = registerStore( MODULE_KEY, {
	reducer: restrictPersistence( reducer, 'preferences' ),
	selectors,
	actions,
	persist: true,
} );
applyMiddlewares( store );

forOwn( tokens, ( { name, settings } ) => {
	settings = validateTokenSettings( name, settings, store.getState() );

	if ( settings ) {
		store.dispatch( actions.registerToken( name, settings ) );
	}
} );

export default store;
github WordPress / gutenberg / packages / annotations / src / store / index.js View on Github external
*/
import { registerStore } from '@wordpress/data';

/**
 * Internal dependencies
 */
import reducer from './reducer';
import * as selectors from './selectors';
import * as actions from './actions';

/**
 * Module Constants
 */
const MODULE_KEY = 'core/annotations';

const store = registerStore( MODULE_KEY, {
	reducer,
	selectors,
	actions,
} );

export default store;
github htmlburger / carbon-fields / packages / blocks / store / index.js View on Github external
/**
 * External dependencies.
 */
import { registerStore } from '@wordpress/data';

/**
 * Internal dependencies.
 */
import reducer from './reducer';
import * as actions from './actions';
import * as selectors from './selectors';

/**
 * Register the store.
 */
registerStore( 'carbon-fields/blocks', {
	reducer,
	actions,
	selectors
} );
github GraphQLAPI / graphql-api-for-wp / packages / components / src / store / index.js View on Github external
/**
 * Block editor data store configuration.
 *
 * @see https://github.com/WordPress/gutenberg/blob/master/packages/data/README.md#registerStore
 *
 * @type {Object}
 */
export const storeConfig = {
	reducer,
	selectors,
	actions,
	controls,
	resolvers,
};

const store = registerStore( MODULE_KEY, storeConfig );

export default store;
github WordPress / gutenberg / packages / block-directory / src / store / index.js View on Github external
/**
 * Block editor data store configuration.
 *
 * @see https://github.com/WordPress/gutenberg/blob/master/packages/data/README.md#registerStore
 *
 * @type {Object}
 */
export const storeConfig = {
	reducer,
	selectors,
	actions,
	controls,
	resolvers,
};

const store = registerStore( MODULE_KEY, storeConfig );

export default store;
github WordPress / health-check / src / javascript / troubleshooting-mode / Stores / Plugins / Plugins.js View on Github external
enablePlugin( plugin ) {
		return {
			type: 'ENABLE_PLUGIN',
			plugin,
		};
	},

	fetchFromAPI( path ) {
		return {
			type: 'FETCH_FROM_API',
			path,
		};
	},
};

registerStore(
	'site-health-plugins', {
		reducer( state = SiteHealth_TroubleshootingMode_DefaultState_Plugins, action ) {
			switch ( action.type ) {
				case 'SET_PLUGINS':
					return {
						...state,
						plugins: action.plugins
					};
				case 'ENABLE_PLUGIN':
					return {
						...state,
						plugins: {
							...state.plugins,
							[ action.plugin.slug ]: action.plugin,
						},
					};
github Automattic / sensei / assets / data-port / export / store / index.js View on Github external
const registerExportStore = () =>
	registerStore( EXPORT_STORE, {
		reducer: createReducerFromActionMap( reducers, EMPTY_STATE ),
		actions,
		selectors,
		resolvers,
		controls: { ...dataControls, ...scheduleControls },
	} );