// Define typed state interface
interface PumpState {
active: boolean;
flowRate: number;
temperature: number;
lastMaintenance: string;
}
const pumpState = StateBean.instance('pump-monitor')
.options({ path: 'assembly.pumps.pump1' })
.build() as StateBean<PumpState>;
// Type-safe property access
const isActive = pumpState.props.get('active') as boolean;
const currentFlow = pumpState.props.get('flowRate') as number;
const temp = pumpState.props.get('temperature') as number;
const maintenance = pumpState.props.get('lastMaintenance') as string;
Reactive Map-based storage for state properties with type safety.
This Map provides efficient storage and retrieval of state properties with automatic reactivity through MobX observables. The Map structure allows for dynamic property addition/removal while maintaining type safety for known properties.