Flexweave
API Reference

Attribute

Stored numeric attributes, mutation hooks, and change facts.

Public exports:

  • AttributeValue
  • Attribute
  • AttributeSet
  • AttributeChange
  • AttributeMutationRequest
  • AttributeMutation
  • AttributeMutationHooks
  • AttributeMutationDecision
  • AttributeMutationResult
  • AttributeMutationRejection

Attribute stores signed numeric values by object id. attach and detach seed or remove values without lifecycle facts.

Attribute

APIBehavior
newCreates an empty attribute channel.
attachSeeds or overwrites a value without notifying listeners.
detachRemoves the stored value without emitting an attribute-change fact.
add_listenerRegisters a listener in deterministic order.
subscribeAlias for add_listener.
hasReturns whether an id has a value.
getReturns Option<AttributeValue>.
countReturns the number of stored values.

Mutation Commands

AttributeSet mutates a value and returns Unchanged, Committed, or Rejected.

APIBehavior
AttributeSet::newCreates a mutation request from id and requested value.
AttributeSet::requestCreates a mutation request from AttributeMutationRequest.
with_hooksAdds ordered pre/post mutation hooks and context.
runApplies the mutation and drops the streaming callback.
run_streamingApplies the mutation and receives committed AttributeChange facts.

Mutation hooks can allow, transform, reject, or observe changes. Ordering is: pre-hooks, storage commit, listeners, post-hooks, streaming callback.

Mutation Types

TypePurpose
AttributeMutationRequestRequested object id and requested value.
AttributeMutationHook view with previous, requested, current, and context.
AttributeMutationDecisionAllow, Transform(value), or Reject(error).
AttributeMutationRejectionRejection details returned from a rejected mutation.
AttributeMutationResultUnchanged, Committed, or Rejected.
AttributeChangeCommitted change with previous, requested, and current.

AttributeChange::delta subtracts previous from current, treating missing previous value as 0.0.

AttributeChange implements LifecycleEvent with LifecycleEventKind::AttributeChanged.

On this page