Skip to content

meteor-sync-eventemitter 1.0.4

Install from the command line:
Learn more about npm packages
$ npm install @activitree/meteor-sync-eventemitter@1.0.4
Install via package.json:
"@activitree/meteor-sync-eventemitter": "1.0.4"

About this version

meteor-sync-eventemitter

Allows syncing event emitter events over multiple meteor servers.

Installation

  npm install meteor-sync-eventemitter

Usage

Normal EventEmitters

  import sync from 'meteor-sync-eventemitter';
  import EventEmitter from 'events';

  @sync({
    collectionName: 'syncedeventemitter', // the collection can only be used for one event emitter.
    emitFn: 'emit', // [optional] if the emit function of the event emitter differs from the default one.
    setIndex: true, // [optional] per default, we create a expiring index to delete entries after 60 seconds.
  })
  class SyncedEventEmitter extends EventEmitter {
    // …
  }

  const eventEmitter = new SyncedEventEmitter();
  eventEmitter.emit('hello');
  eventEmitter.on('hello', () => console.log('world')); // would be triggered on all servers

rocketchat:streamer

  import { Meteor } from 'meteor/meteor';
  import sync from 'meteor-sync-eventemitter';

  @sync({ collectionName: 'stream', emitFn: '_emit' })
  class SyncedStream extends Meteor.Streamer {
    constructor() {
      super('streamname');
      this.allowRead(  );
      this.allowWrite(  );
    }
  }

  const stream = new SyncedStream()
  stream.emit(  );
  stream.on(  );

License

Licensed under MIT license. Copyright (c) 2017 Max Nowack

Contributions

Contributions are welcome. Please open issues and/or file Pull Requests.

Maintainers

Details


Assets

  • meteor-sync-eventemitter-1.0.4.tgz

Download activity

  • Total downloads 2
  • Last 30 days 0
  • Last week 0
  • Today 0

Recent versions

View all