Flexweave
API Reference

Lifecycle

Lifecycle event kinds, event channels, route definitions, and retention.

Public exports:

  • LifecycleEventKind
  • LifecycleEvent
  • LocalLifecycleEvent
  • EventChannelDefinition
  • EventChannelDefinitions
  • EventChannelRouteDefinition
  • EventChannel
  • EventRetention
  • EventConnectionHandle
  • ScopedEventConnection
  • EventChannelDefinitionError
  • EventChannelError

EventChannel validates payload kind, optionally retains owned events, and notifies listeners in registration order.

Event Kinds

LifecycleEventKind is the stable classifier used by channels, routes, signal projection, and lifecycle facts.

FamilyKinds
AttributeAttributeChanged, DerivedAttributeChanged
EffectEffectApplicationAccepted, EffectApplicationRejected, EffectActiveCreated, EffectExecuted, EffectPeriodicExecuted, EffectAdvanced, EffectRemoved, EffectExpired
SignalSignalReinvoked
AbilityAbilityActivationAttempted, AbilityActivationRejected, AbilityActivationCommitted, AbilityActivationStarted, AbilityActivationCanceled, AbilityActivationRevoked, AbilityActivationRolledBack, AbilityActivationEnded

LifecycleEvent is implemented by primitive fact types so channels can validate a fact's kind before publication.

Channel Definitions

Type/APIBehavior
EventChannelDefinition::newValidates channel name and accepted payload kinds.
nameReturns the stable channel name.
accepted_kindsReturns the accepted lifecycle kinds.
acceptsTests one lifecycle kind.
validate_payload_kindReturns definition error on mismatch.
EventChannelDefinitions::newBuilds a duplicate-free definition collection.
definitionsReturns definitions in declaration order.
getLooks up a channel definition by name.
validate_routeValidates a named route against channel definitions.
EventChannelRouteDefinition::newCreates a source-kind to channel-name route.

Channel names accept ASCII alphanumeric characters plus ., _, -, :, and /.

Runtime Channels

APIBehavior
EventChannel::newCreates a drop-retention channel.
with_retentionCreates a channel with Drop or Retain.
definitionReturns the channel definition.
nameReturns the channel name.
retentionReturns retention policy.
listener_countCounts connected listeners.
subscribeRegisters a listener and returns a handle.
subscribe_scopedRegisters a listener disconnected on guard drop.
retainedReturns retained events.
drain_retainedDrains retained events in emission order.
compact_disconnectedRemoves disconnected listeners.
publishPublishes an owned event.
publish_borrowedPublishes a borrowed event to non-retained channels.

Borrowed publication is only allowed on non-retained channels. Retained channels require owned events.

Errors

EventChannelDefinitionError covers invalid channel names, empty payload contracts, duplicate payload kinds, duplicate channel definitions, missing definitions, and route payload mismatch.

EventChannelError covers runtime publication payload mismatch and borrowed publication into retained channels.

On this page