1.0.1 • Published 10 years ago
qipp-services-pubsub v1.0.1
qipp-services-pubsub

General
The pubsub service provides event methods per topic to extend objects, therefore allowing subscription/unsubscription/emission.
Install
npm i qipp-services-pubsubAngular usage
First, use the pubsub() method to extend a given object:
function inc() {
obj.prop++
}
var obj = pubsub({prop: 1})
obj.$on('anEvent', inc)
obj.$emit('anEvent') // obj {prop: 2}
obj.$off('anEvent')
obj.$emit('anEvent') // No change: obj {prop: 2}Note that the unsubscription could be done for a specific callback:
obj.$off('anEvent')Moreover, the subscription/unsubscription could be done on multiple topics simultaneously:
obj.$on('anEvent' 'anotherEvent')
obj.$off('anEvent' 'anotherEvent')Tools
Linting with StandardJS
Please refer to the JavaScript Standard Style for general rules.
npm run lintUnit testing with Karma
npm testRequirements
Angular
- angular 1.4.3
Licence
Released under the MIT license by qipp.