Skip to content

Instantly share code, notes, and snippets.

@danielbischoff
Created February 26, 2018 20:27
Show Gist options
  • Save danielbischoff/50c8f5ce00f557da2a75701816928aa2 to your computer and use it in GitHub Desktop.
Save danielbischoff/50c8f5ce00f557da2a75701816928aa2 to your computer and use it in GitHub Desktop.
class MyStore {
@observable.ref deviceStatus; // Device status is sth. like { isConnected, etc. }
@action
updateStatus = (deviceStatus) => {
this.deviceStatus = deviceStatus;
}
};
const store = new MyStore();
const websocket = new WebSocket(...);
websocket.onmessage = function (event) {
store.updateStatus(JSON.parse(event.data));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment