Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Data Binding Example

Demonstrates Nemo's data source binding system — XML-configured data sources that feed live data into UI components through declarative bindings.

Screenshot

Quick Start (No External Dependencies)

The example works out of the box with the built-in timer and HTTP data sources:

cargo run -- --app-config examples/data-binding/app.xml
  • The timer source updates a tick counter every second
  • The HTTP source polls httpbin.org every 30 seconds
  • Click "Read Data" to read current data via RHAI scripts
  • Click "Write Data" to write data and observe binding propagation

With Docker Services (MQTT, Redis, NATS)

For testing messaging protocol sources, start the Docker services:

cd examples/data-binding
docker compose up -d

Then uncomment the relevant <source> elements in app.xml and restart.

Testing MQTT

# Publish a test message
mosquitto_pub -t sensors/temperature -m '{"value": 23.5, "unit": "C"}'

Testing Redis

# Publish to a channel
redis-cli PUBLISH app-events '{"type": "alert", "message": "Hello from Redis"}'

Testing NATS

# Publish a message
nats pub updates.test '{"status": "ok"}'

Mock Data Plugin

Build the mock data plugin for simulated sensor data:

cargo build -p mock-data-plugin

Load it by adding a plugin path to your configuration.

XML Configuration Reference

Data Sources

<data>
  <source name="ticker" type="timer" interval="1" />
  <source name="api" type="http" url="https://example.com" interval="30" />
</data>

Bindings

<label id="display" bind-text="data.source_name" />

<!-- Explicit binding element -->
<label id="display" text="waiting...">
  <binding source="data.source_name.field" target="text"
           mode="one_way" transform="payload.temperature" />
</label>

Sinks

<data>
  <sink name="output" type="mqtt" topic="commands" host="localhost" port="1883" />
</data>

RHAI Script API

// Read data from a source
let data = get_data("source_name");

// Write data (triggers binding propagation)
set_data("path.to.data", value);

// Read/write component properties
let text = get_component_text("component_id");
set_component_text("component_id", "new text");