qipp-services-pubsub

    1.0.1 • Public • Published

    qipp-services-pubsub Build Status npm version

    General

    The pubsub service provides event methods per topic to extend objects, therefore allowing subscription/unsubscription/emission.

    Install

    npm i qipp-services-pubsub

    Angular 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 lint

    Unit testing with Karma

    npm test

    Requirements

    Angular

    Licence

    Released under the MIT license by qipp.

    Install

    npm i qipp-services-pubsub

    DownloadsWeekly Downloads

    5

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • qipp