Saturday 20 May 2017

Knockout Subscribe - User update vs system update

I currently have a multi-client application running in NodeJS with a Knockout, HTML, JS front-end. I have some fields on the page with Knockout subscriptions so that when a user makes a change, it is sent to the server and then broadcasted to the server.

this.Name.subscribe(function(newValue) {
      Helpers.SendUpdate(this._id, "resources", { "Name": newValue });
}, this);

The other clients get the messages fine and then update the fields as needed but my problem is that the when the field is updated by the system it triggers another update to be sent to the server as the subscription is triggered and all kinds of cyclic badness insues.

Is there a clever way you guys can think of knowing if an action is triggered by the user or the system?



via Jareth

No comments:

Post a Comment