Is it possible to, so to speak, publish without an existing or persistent collection? My goal is to make an EventEmitter that emits on both the client and the server. net.Socket
won’t work on the client
// on the server
import {Socket} from 'net';
import {EventEmitter} from 'events';
export class MySpecialClass extends EventEmitter {
constructor() {
super();
this._messages = new Socket();
}
get messages() {
return this._messages;
}
}
export const special = new MySpecialClass();
Meteor.publish(null, function () {
const listener = Meteor.bindEnvironment(data => {
// publish to client-side event emitter
});
special.messages.on('data', listener);
this.ready();
this.onStop(() => special.messages.removeListener('data', listener));
});