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
Allows syncing event emitter events over multiple meteor servers.
npm install meteor-sync-eventemitter
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
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( … );
Licensed under MIT license. Copyright (c) 2017 Max Nowack
Contributions are welcome. Please open issues and/or file Pull Requests.
- Max Nowack (maxnowack)
Details
- meteor-sync-eventemitter
- activitree
- about 1 year ago
- MIT
- 8 dependencies
Assets
- meteor-sync-eventemitter-1.0.4.tgz
Download activity
- Total downloads 2
- Last 30 days 0
- Last week 0
- Today 0