Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Callbacks

Registers, replaces or removes the functions the host calls with live updates.

bridge.setCallbacks(callbacks)  // → void

Parameters

Name
Type
Required
Description

callbacks

object | null

yes

Any of the six callback names below. Omitted keys stay as they are; null for a key removes that callback; setCallbacks(null) removes all six

A value that isn't a function or null is reported through sendError, and that key is skipped.

Callback
Called with
Web
Mobile

onValueUpdated

One ValueObject, with the full field set

✅ every server push

✅ every server push

onThemeUpdated

The same object getTheme() resolves with

✅ light/dark and branding changes

✅ light/dark (or a reload), and late-loading fonts

onHistoricalDataUpdated

{ streams }, as from getHistoricalData

✅ after a RANGE_PICKER subscription

— never emitted

onMapDataUpdated

{ points }, as from getMapData

✅ after a RANGE_PICKER subscription

— never emitted

onDeviceMetadataUpdated

One committed metadata descriptor

✅

✅

onError

A human-readable message string

✅

✅

Example

bridge.setCallbacks({
  onValueUpdated: (v) => applyValue(v.index, v),
  onThemeUpdated: (theme) => applyTheme(theme),
  onHistoricalDataUpdated: ({ streams }) => renderChart(streams),
  onMapDataUpdated: ({ points }) => drawTrack(points),
  onDeviceMetadataUpdated: (descriptor) => renderMetadata(descriptor),
  onError: (message) => showErrorBanner(message)
});

bridge.setCallbacks({ onDeviceMetadataUpdated: null });   // remove one
  • Register callbacks before the initial reads, and make rendering safe to repeat.

  • onDeviceMetadataUpdated suppresses identical snapshots and gets a shallow copy of the descriptor.

  • Synchronous exceptions thrown by a callback are caught and logged; exceptions from onError are swallowed. A rejected Promise from an async callback is not caught — handle it inside the callback.

  • onError runs only while isOnErrorEnabled is true (the default).

Was this helpful?