@wordpress/e2e-tests
Version:
Test plugins and mu-plugins for E2E tests in WordPress.
25 lines (23 loc) • 474 B
JavaScript
/**
* WordPress dependencies
*/
import { store, getContext, withScope } from '@wordpress/interactivity';
store( 'with-scope', {
callbacks: {
asyncInit: () => {
setTimeout(
withScope( function* () {
yield new Promise( ( resolve ) =>
setTimeout( resolve, 1 )
);
const context = getContext();
context.asyncCounter += 1;
}, 1 )
);
},
syncInit: () => {
const context = getContext();
context.syncCounter += 1;
},
},
} );