2.1.0 • Published 3 years ago

topic-dispatch v2.1.0

Weekly downloads
20
License
MIT
Repository
-
Last release
3 years ago

Topic Dispatch

A way to bind function(s) to a topic using AMQP style matching rules. Not optimized for situations with a lot of "topic churn".

It is probably not for you. Check out Jim Cowart's monologue or postal instead.

API

const topics = require('topic-dispatch')

topics.on('*', (event, topic) => {}) // catch all
topics.on('#', (event, topic) => {}) // catch all
topics.on('*', (event, topic) => {}) // catch 'connected'
topics.on('account.*', (event, topic) => {}) // catch anything starting with 'account'
topics.on('*.created', (event, topic) => {}) // catch anything ending in .created'
topics.on('account.#', (event, topic) => {}) // catch any two segment topic beginning with `account`
topics.on('#.created', (event, topic) => {}) // catch any two segment topic ending with `created`
topics.once('ready', (event, topic) => {}) // removes itself after one even is received

function handler = () => {}
topics.on('added', handler)
topics.removeListener('added', handler) // removes specific handler from a topic

topics.on('added', () => {})
topics.on('added', () => {})
topics.on('added', () => {})
topics.removeAllListeners('added') // removes all handlers from topic

topics.emit('account.created', {}) // will call all but one of the functions listed above

topics.cleanup() // erase all bindings
2.1.0

3 years ago

2.0.0

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago