Demonstrates Nemo's data source binding system — XML-configured data sources that feed live data into UI components through declarative bindings.
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
For testing messaging protocol sources, start the Docker services:
cd examples/data-binding
docker compose up -dThen uncomment the relevant <source> elements in app.xml and restart.
# Publish a test message
mosquitto_pub -t sensors/temperature -m '{"value": 23.5, "unit": "C"}'# Publish to a channel
redis-cli PUBLISH app-events '{"type": "alert", "message": "Hello from Redis"}'# Publish a message
nats pub updates.test '{"status": "ok"}'Build the mock data plugin for simulated sensor data:
cargo build -p mock-data-pluginLoad it by adding a plugin path to your configuration.
<data>
<source name="ticker" type="timer" interval="1" />
<source name="api" type="http" url="https://example.com" interval="30" />
</data><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><data>
<sink name="output" type="mqtt" topic="commands" host="localhost" port="1883" />
</data>// 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");
