How to use the @wordpress/data.plugins 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 / react-native-editor / src / index.js View on Github external
const gutenbergSetup = () => {
	const wpData = require( '@wordpress/data' );

	// wp-data
	const userId = 1;
	const storageKey = 'WP_DATA_USER_' + userId;
	wpData.use( wpData.plugins.persistence, { storageKey } );
};
github wordpress-mobile / gutenberg-mobile / src / index.js View on Github external
const gutenbergSetup = () => {
	const wpData = require( '@wordpress/data' );

	// wp-data
	const userId = 1;
	const storageKey = 'WP_DATA_USER_' + userId;
	wpData.use( wpData.plugins.persistence, { storageKey } );
};
github DefinitelyTyped / DefinitelyTyped / types / wordpress__data / wordpress__data-tests.tsx View on Github external
import * as data from '@wordpress/data';

data.select('core/block-editor').isTyping();
data.dispatch('core/block-editor').resetBlocks('');

data.use(data.plugins.persistence, { storage: window.localStorage });

interface FooBar {
    foo: string;
    bar: number;
}

data.registerStore('foo', {
    reducer(state = { foo: 'foo', bar: 21 }, action) {
        return state;
    },
    selectors: {
        getFoo: ({ foo }) => foo,
        getBar: ({ bar }) => bar,
        getSomething: (state, thing: keyof FooBar) => state[thing],
    },
    actions: {
github front / gutenberg-js / src / js / scripts / data.js View on Github external
import * as data from '@wordpress/data';

const uid = window.userSettings ? window.userSettings.uid || 1 : 1;
const storageKey = `WP_DATA_USER_${uid}`;

data.use(data.plugins.persistence, { storageKey });
data.use(data.plugins.controls);
github front / gutenberg-js / src / js / scripts / data.js View on Github external
import * as data from '@wordpress/data';

const uid = window.userSettings ? window.userSettings.uid || 1 : 1;
const storageKey = `WP_DATA_USER_${uid}`;

data.use(data.plugins.persistence, { storageKey });
data.use(data.plugins.controls);