diff --git a/lib/server.js b/lib/server.js index bda32e6..d1ee79e 100644 --- a/lib/server.js +++ b/lib/server.js @@ -2,7 +2,7 @@ var EventEmitter = Npm.require('events').EventEmitter; var util = Npm.require('util'); var Fibers = Npm.require('fibers'); -Meteor.Stream = function Stream(name) { +Meteor.Stream = function Stream(name, localEmit) { EV.call(this); var self = this; @@ -21,6 +21,12 @@ Meteor.Stream = function Stream(name) { self._emit = self.emit; self.emit = function emit() { + // emit the event to the server so others - i.e. other packages - can react + // to the event (useful when creating your own packages and no db needs to + // be involved) + if ( localEmit ) { + self._emit(arguments[0], arguments[1]); + } self.emitToSubscriptions(arguments, null, null); }; @@ -111,4 +117,4 @@ Meteor.Stream = function Stream(name) { } }; -util.inherits(Meteor.Stream, EV); \ No newline at end of file +util.inherits(Meteor.Stream, EV);