Skip to content
This repository has been archived by the owner on Jul 9, 2018. It is now read-only.

Commit

Permalink
Improve hooks docs (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Silverstein authored and gziolo committed May 7, 2018
1 parent 3dbd3a5 commit 6c114c1
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions packages/hooks/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @wordpress/hooks

A lightweight & efficient EventManager for JavaScript in WordPress.
A lightweight & efficient EventManager for JavaScript.

## Installation

Expand All @@ -11,10 +11,15 @@ npm install @wordpress/hooks --save
```

### Usage
In your JavaScript project, use hooks as follows:
```javascript
import { createHooks } from '@wordpress/hooks';

API functions can be called via the global `wp.hooks` like this `wp.hooks.addAction()`, etc.
myObject.hooks = createHooks();
myObject.hooks.addAction(); //etc...
```

A lightweight & efficient filter and action manager.
In the WordPress context, API functions can be called via the global `wp.hooks` like this `wp.hooks.addAction()`, etc.

### API Usage

Expand All @@ -36,12 +41,6 @@ A lightweight & efficient filter and action manager.
* `actions`
* `filters`

Hooks can be added to an object via composition:
`import { createHooks } from '@wordpress/hooks';`

`myObject.hooks = createHooks();`

API functions are then be called: `myObject.hooks.addAction()`.

### Events on action/filter add or remove

Expand Down

0 comments on commit 6c114c1

Please sign in to comment.