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

Improve hooks docs #121

Merged
merged 1 commit into from
May 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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