Skip to main content

Data Layer (react_ui/src/data/)

State management, engine↔JS bridge, and real-time metering.

Files

Real-Time Metering Pipeline

Three-Layer Architecture

  1. rtBuffer — Raw mutable object, written by the engine event handler. No subscriptions, no notifications. Just a data landing zone.
  2. displayBuffer — Smoothed values computed by the requestAnimationFrame loop. Applies ballistic smoothing so meters look fluid even with 30Hz data input. Subscribers receive this.
  3. useMeterStore (Zustand) — Throttled to ~10Hz for the few React components that still use reactive selectors. Most components use subscribeRtBuffer instead.

Ballistic Smoothing Constants

Attack is always instant — when the new value exceeds the current smoothed value, it snaps immediately.

API

Rendering Best Practices

All meter components use direct DOM manipulation via subscribeRtBuffer (no React re-renders): Why transforms? height/width/left trigger browser layout recalculation (~0.5ms per property). transform is GPU-composited — the browser sends a matrix to the GPU with no layout cost.

Event Flow