Back to Wails

Function JSONStream

v3/internal/runtime/desktop/@wailsio/runtime/docs/functions/JSONStream.html

2.15.0861 B
Original Source
  • JSONStream

Function JSONStream

JSONStream(name: string): JSONSocket

A Stream that speaks objects instead of bytes.

send(value) marshals with JSON.stringify, and ev.data in an onmessage handler is the parsed object rather than an ArrayBuffer. Pairs with StreamConn.SendJSON / ReceiveJSON on the Go side.

const s = JSONStream("telemetry");s.onmessage = (ev) => console.log(ev.data.temperature);s.onopen = () => s.send({ subscribe: "sensors" });Copy

A frame that is not valid JSON raises an error event and is dropped, rather than throwing from the poll loop and taking the connection down with it.

Parameters

  • name: string

Returns JSONSocket

Settings

Member Visibility

  • Protected
  • Inherited
  • External

ThemeOSLightDark