Created
February 26, 2018 20:27
-
-
Save danielbischoff/50c8f5ce00f557da2a75701816928aa2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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