@emisor/plugin-count

    1.0.0-alpha.7 • Public • Published

    Count Plugin for Emisor

    This plugin add support for subscribing for a x amount of time to a event

    Plugin options

    key type default description
    key string count

    count options

    the count option should always be a number what will be the max amount of time the subscriber can be triggered

    postfix options

    the postfix format is #N where N is e.q. to count option

    Examples

    import { EmisorCore } from '@emisor/core';
    import { EmisorPluginCount } from '@emisor/plugin-count';
     let Emitter = new EmisorCore({
          plugins: [
            new EmisorPluginCount()
          ]
        });
    //subscribe once
    Emitter.on('test', () => console.count('test'), { count: 1 });
    
    Emitter.emit('test') //will log "test: 1"
    Emitter.emit('test') //will log nothing
    
    //subscribe 3
    Emitter.on('test', () => console.count('test'), { count: 3 });
    
    Emitter.emit('test') //will log "test: 1"
    Emitter.emit('test') //will log "test: 2"
    Emitter.emit('test') //will log "test: 3"
    Emitter.emit('test') //will log nothing
    
    //subscribe once
    Emitter.on('test:#1', () => console.count('test'));
    Emitter.emit('test') //will log "test: 1"
    Emitter.emit('test') //will log nothing

    Keywords

    none

    Install

    npm i @emisor/plugin-count

    DownloadsWeekly Downloads

    3

    Version

    1.0.0-alpha.7

    License

    Apache License v2.0

    Unpacked Size

    17.6 kB

    Total Files

    6

    Last publish

    Collaborators

    • victor-perez