I am trying to make a button component. When clicked, it will disable and say what it’s currently doing (read from a server collection).
On my client I have something similar to as follows
Template['MachineButton'].onCreated(function () {
this.lastMessage = new ReactiveVar('OK');
this.executing = new ReactiveVar(false);
FlowRouter.subsReady('machine', () => {
Machine.connections.find({ name: 'messages' }).observe({
changed: (doc) => {
this.lastMessage.set(_.last(doc.messages).message);
}
});
});
});
My server does something like as follows:
// factory method to create TCP sockets
Machine._messages = Machine._createConnection('names');
Machine._messages.addListener('data', function (data) {
Machine.connections.update({ name: 'messages' }, {
$push: {
$each: [{
timestamp: new Date,
message: data.toString('ascii')
}],
$sort: { timestamp: 1 },
$slice: -20
}
});
});
It seems like this executes too slowly. It never changes the messages on the page, even though it seems like it should. Why does this happen? Is it long-polling? How can you tell?