Learn
Observable data and lifecycle
Understand replay-latest delivery, ordering, errors, closing, and ownership.
Observable data and lifecycle
data returns the latest committed value synchronously. stream is a replay-latest broadcast stream: each new listener receives the current value, followed by later commits.
Ordering
Publication is asynchronous. Commits are queued in acceptance order and callbacks never run on the setData call stack. A listener that commits another value does not recursively re-enter itself.
State, not an event log
The stream represents current business data. It is not a durable event log and does not promise exactly-once delivery. Event-history requirements need a transactional outbox, event store, or another durable mechanism.
Closing
close() is idempotent. It rejects later commits, invokes closeRepository(), closes current subscriptions, and keeps the last data value readable. A Repository must not close shared DataSources merely because they appear in its container.
Recommended shutdown order:
- bindings that can submit work;
- UseCases and application services;
- repositories;
- DataSources and technical clients.