1.0.3 • Published 6 years ago

@peepso/hooks v1.0.3

Weekly downloads
1
License
MIT
Repository
gitlab
Last release
6 years ago

Hooks

WordPress-like filter and action hooks implementation.

Installation

npm install @peepso/hooks --save

Usage

import Hooks from '@peepso/hooks';

// You can instantiate it manually like in the example below:
let hooks = new Hooks();
hooks.addAction( 'actionName', 'fnName', ( ...args ) => console.log( args ) );

// Or, you can extend it to another class:
class Person extends Hooks {
	constructor() {
		this.addAction( 'actionName', 'fnName', ( ...args ) => console.log( args ) );
	}
}

Methods

Filter methods

addFilter( filterName, handlerName, handler, [priority=10] )
removeFilters( filterName, [handlerName, [handler]] )
applyFilters( filterName, ...args )

Action methods

addAction( actionName, handlerName, handler, [priority=10] )
removeActions( actionName, [handlerName, [handler]] )
doAction( actionName, ...args )

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.1.0

6 years ago