Skip to content

Commit d36eadb

Browse files
committed
changed author into userId
added sepatate context for each listening method invocation
1 parent 34defcd commit d36eadb

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

laika/tests/basic.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ suite('Basic Communication', function() {
7979

8080
c1.evalSync(function() {
8181
helloStream.on('evt', function(data) {
82-
emit('evt', this.author, data);
82+
emit('evt', this.userId, data);
8383
});
8484
emit('return');
8585
});
8686

87-
c1.on('evt', function(author, data) {
88-
assert.ok(author);
87+
c1.on('evt', function(userId, data) {
88+
assert.ok(userId);
8989
assert.deepEqual(data, {abc: 10012});
9090
done();
9191
});

lib/client.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ Meteor.Stream = function Stream(name, callback) {
1414
if(item.type == 'subscriptionId') {
1515
subscriptionId = item._id;
1616
} else {
17-
self.subscriptionId = item.subscriptionId;
18-
self.author = item.author;
19-
self._emit.apply(self, item.args);
17+
var context = {};
18+
context.subscriptionId = item.subscriptionId;
19+
context.userId = item.userId;
20+
self._emit.apply(context, item.args);
2021
}
2122
}
2223
});

lib/server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ Meteor.Stream = function Stream(name) {
3131
filters.push(callback);
3232
};
3333

34-
function emitToSubscriptions(args, subscriptionId, author) {
35-
events.emit('item', {args: args, author: author, subscriptionId: subscriptionId});
34+
function emitToSubscriptions(args, subscriptionId, userId) {
35+
events.emit('item', {args: args, userId: userId, subscriptionId: subscriptionId});
3636
}
3737

3838
Meteor.publish(streamName, function() {

0 commit comments

Comments
 (0)