0.3.3 • Published 10 years ago

node-pluggable v0.3.3

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

node-pluggable

Add your Hook more easily.

Build Status

Demo

Installation

npm install node-pluggable

API

Pluggable = require 'node-pluggable'
plugin = new Pluggable()

use(match_param , hook_callback...) => this

plugin.use('article.create', (article, next) ->
  article.hook = 'article.create'
  next()
)
  • this method is similar to connect
  • match_param must be string or regex
  • hook_callback will be called when param is matched

run(param, hook_callback_params..., callback) => this

article =
  title: 'title'
  author: 'author'
  content: 'content'

plugin.run 'article.create', article, ->
  console.log article
  • param will match with match_param, which must be string
  • hook_callback_params will be send to hook_callback

bind(hook_name, hook_callback...) => this

plugin.bind 'article.update', (article) ->
  console.log article
, (article) ->
  console.log article.length
  • hook_callback will be called when event be emitted

on(hook_name, hook_callback) => this

plugin.on 'article.update', (article) ->
  console.log article
  • similar to bind

emit(hook_name, data) => this

plugin.emit 'article.update', 'just a message.'

  • emit an event

License

MIT

0.3.3

10 years ago

0.3.2

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.5

10 years ago

0.2.4

10 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.1

10 years ago