Advanced

Modular expression implementation

rs-x is a highly extendable framework: you can add support for custom data types without rewriting the runtime core. Modular expression support was added in exactly that way, by introducing a focused plugin set for the Expression value type.

See also: Core concepts: Modular expressions

Detailed notes

  • rs-x was built to be extended and adaptable. It has extension points for value access, value metadata, observer factories, and deep-clone value handling, so we can add a new value type without changing the runtime core.
  • First, ExpressionMetadata tells the runtime that AbstractExpression is a supported value type and that it should be handled as async/proxy-aware.
  • Next, ExpressionIndexAccessor defines how expression members are read (`expression.value`) and intentionally blocks direct `setValue` writes.
  • Then, ExpressionObserverFactory provides one reusable observer per expression and forwards `expression.changed` events into state-manager change events.
  • After that, ExpressionObserverProxyPairFactory connects expression objects to the observer pipeline by handling values that are `AbstractExpression` instances and delegating observer creation to `IExpressionObserverFactory`.
  • Finally, DeepCloneExceptWithExpressionSupport makes clone/evaluation paths unwrap `expression.value` (or `PENDING` when unresolved), so modular expressions compose correctly with other values.
  • Result: modular expressions behave like a native runtime value type and participate fully in tracking, observation, and evaluation flows.