Flexweave
API Reference

Derived Attribute

Calculated numeric attributes with explicit refresh.

Public exports:

  • DerivedAttribute
  • DerivedAttributeRefresh
  • DerivedChange

DerivedAttribute::new accepts a calculator closure from ObjectId to Option<AttributeValue>.

DerivedAttribute

APIBehavior
newCreates a derived channel from a calculator closure.
add_listenerRegisters a listener in deterministic order.
subscribeAlias for add_listener.
getEvaluates the calculator without mutating tracked cache.
hasReturns whether the calculator currently produces a value.
countReturns the number of tracked cached values.
untrackRemoves the tracked cache entry without running the calculator.
syncSeeds or overwrites tracked cache without notification.

Refresh Commands

get evaluates without mutating tracked cache. sync seeds or overwrites the tracked cache without notification. DerivedAttributeRefresh evaluates and emits a DerivedChange only when the tracked value changes.

APIBehavior
DerivedAttributeRefresh::newRefreshes even when no cached value was tracked before.
DerivedAttributeRefresh::trackedRefreshes only if the id already has a tracked cache value.
tracked_onlyConverts an existing refresh command to tracked-only mode.
runRefreshes and returns the current value.
run_streamingRefreshes and streams emitted DerivedChange facts.

Use untrack when an object leaves the runtime.

DerivedChange::delta subtracts previous from current, treating missing values as 0.0.

DerivedChange implements LifecycleEvent with LifecycleEventKind::DerivedAttributeChanged.

On this page