How to use the @wordpress/hooks.removeAction function in @wordpress/hooks

To help you get started, we’ve selected a few @wordpress/hooks 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 DefinitelyTyped / DefinitelyTyped / types / wordpress__hooks / wordpress__hooks-tests.ts View on Github external
import * as hooks from '@wordpress/hooks';

hooks.addAction('my-action', 'my/namespace', () => {});
hooks.addAction('my-action', 'my/namespace', () => {}, 20);

hooks.addFilter('my-filter', 'my/namespace', (foo: string, bar: number) => `${foo}${bar}`);
hooks.addFilter('my-filter', 'my/namespace', (foo: number, bar: number) => bar, 23);

hooks.removeAction('my-action', 'my/namespace');
hooks.removeFilter('my-filter', 'my/namespace');

// $ExpectType boolean
hooks.hasAction('my-action');
// $ExpectType boolean
hooks.hasFilter('my-filter');

hooks.removeAllActions('my-action', 'my/namespace');
hooks.removeAllFilters('my-filter', 'my/namespace');

// $ExpectType unknown
hooks.doAction('my-action');
// $ExpectType string
hooks.doAction('my-action', 'foo');

// $ExpectType unknown
github gambitph / Stackable / src / help / events-show.js View on Github external
export const stopListening = () => {
	// Turn off help tip styling.
	document.body.classList.remove( 'ugb--help-tips-enabled' )

	stopListeningMouseEvents()
	removeAction( 'stackable.help-video.control.hover.in', 'stackable/help/hoverin' )
	removeAction( 'stackable.help-video.control.hover.out', 'stackable/help/hoverout' )
	removeAction( 'stackable.help-video.control.click', 'stackable/help/click' )
}
github gambitph / Stackable / src / help / events-show.js View on Github external
export const stopListening = () => {
	// Turn off help tip styling.
	document.body.classList.remove( 'ugb--help-tips-enabled' )

	stopListeningMouseEvents()
	removeAction( 'stackable.help-video.control.hover.in', 'stackable/help/hoverin' )
	removeAction( 'stackable.help-video.control.hover.out', 'stackable/help/hoverout' )
	removeAction( 'stackable.help-video.control.click', 'stackable/help/click' )
}
github WordPress / gutenberg / packages / components / src / higher-order / with-filters / index.js View on Github external
componentWillUnmount() {
				FilteredComponentRenderer.instances = without(
					FilteredComponentRenderer.instances,
					this
				);

				// If this was the last of the mounted components filtered on
				// this hook, remove the hook handler.
				if ( FilteredComponentRenderer.instances.length === 0 ) {
					removeAction( 'hookRemoved', namespace );
					removeAction( 'hookAdded', namespace );
				}
			}
github WordPress / gutenberg / src / block-management / block-holder.js View on Github external
onRemoveBlockCheckUpload = ( mediaId: number ) => {
		if ( hasAction( 'blocks.onRemoveBlockCheckUpload' ) ) {
			// now remove the action as it's  a one-shot use and won't be needed anymore
			removeAction( 'blocks.onRemoveBlockCheckUpload', 'gutenberg-mobile/blocks' );
			requestImageUploadCancel( mediaId );
		}
	};
github WordPress / gutenberg / packages / editor / src / components / post-locked-modal / index.js View on Github external
componentWillUnmount() {
		const hookName = this.getHookName();

		removeAction( 'heartbeat.send', hookName );
		removeAction( 'heartbeat.tick', hookName );
	}
github htmlburger / carbon-fields / packages / core / hocs / with-filters / index.js View on Github external
componentWillUnmount() {
				this.throttledForceUpdate.cancel();
				removeAction( 'hookRemoved', this.namespace );
				removeAction( 'hookAdded', this.namespace );
			}
github gambitph / Stackable / src / components / responsive-toggle / index.js View on Github external
componentWillUnmount() {
		const { instanceId } = this.props
		removeAction( 'stackable.responsive-toggle.screen.change', `stackable/responsive-toggle-${ instanceId }` )
		removeAction( 'stackable.responsive-toggle.screen.open', `stackable/responsive-toggle-${ instanceId }` )
		removeAction( 'stackable.responsive-toggle.screen.close', `stackable/responsive-toggle-${ instanceId }` )
	}
github WordPress / gutenberg / packages / editor / src / components / post-locked-modal / index.js View on Github external
componentWillUnmount() {
		const hookName = this.getHookName();

		removeAction( 'heartbeat.send', hookName );
		removeAction( 'heartbeat.tick', hookName );
	}
github gambitph / Stackable / src / help / help-tooltip-video.js View on Github external
return () => {
			removeAction( 'stackable.help-video.show', 'stackable/help' )
			removeAction( 'stackable.help-video.hide', 'stackable/help' )
		}
	}, [] )