-
Notifications
You must be signed in to change notification settings - Fork 0
Functions
molimawka edited this page May 11, 2022
·
3 revisions
Return store for the specified event name
const eventName = wsocket.on(eventName: string)
Local emit event by event name
wsocket.emit(eventName: string, arg: unknown)
Return readable store for websocket readyState
const state = wsocket.getState()
$: $state && onStateChange()
function onStateChange() {
console.log("New state", $state)
}
Open connection. If the connection was not closed (readyState !== WebSocket.CLOSE) then nothing will happen.
wsocket.open()
Open connection. If the connection was not opened (readyState !== WebSocket.OPEN) then nothing will happen.
wsocket.close()
Send data by event name. Send json {event: eventName, data: data}
wsocket.send(eventName: string, data: unknown)
Send string
wsocket.sendPlainText(text: string)