Reactive Execution
RxJS remains the shared execution layer. ExecutionResult<T> accepts a value,
Promise, Observable, or Promise resolving to an Observable. Protocol SDKs retain
their native Promise interfaces at the transport boundary.
Reactive.call({ fn, context, args }) is cold: it invokes the function once per
subscription, preserves this, and sends synchronous exceptions through the
error channel. null, undefined, arrays, and strings are scalar results.
Reactive.toObservable(result) normalizes an existing result; pass a function to
Reactive.call when invocation itself must be deferred.
| Boundary | Consumption |
|---|---|
| REST, GraphQL resolvers, tRPC queries/mutations | First emission, then unsubscribe |
| WebSocket decorated handlers | First emission in the existing reply envelope |
| MCP tools/resources/prompts and ACP handlers | First emission, then native SDK result validation |
| Worker jobs and parent-service RPC | First emission |
| EBS consumers and finite lifecycle hooks | Wait for completion |
| EBS streams, tRPC subscriptions, worker services | Every emission until completion/cancellation |
| CQRS command/query buses | Public Observable results |
Reactive.first(source, signal?) rejects empty completion with
EmptyExecutionError (EMPTY_RESULT). An emitted undefined or null remains a
value, subject to the target protocol’s result requirements. Cancellation rejects
with ExecutionCancelledError (CANCELLED). Reactive.complete(source, signal?)
waits for completion, ignores emitted values, and accepts an empty source.
Request disconnect, protocol cancellation, and application shutdown unsubscribe owned Observable executions. Native Promises need cooperative cancellation in application code. Worker jobs retain their slot until a cancelled Promise settles, or terminate the worker after its grace period. Infinite streams belong in APIs that explicitly support streaming; a unary source must emit or be cancelled.
dispatchAndWait() waits for completion and propagates errors. Dispatch helpers
return subscriptions where applicable, and background execution reports errors.
Event subscriptions have owners; event disposal completes Subjects. Finite service
hooks are awaited, daemon subscriptions are tracked, and interval services skip a
tick while the previous run is active. Existing @Service classes remain on the
main thread.
EBS consumers normalize handlers before treating work as settled, preserving
manual acknowledgement policy. EBS stream publishing remains ordered; publishing
failures propagate, empty sources complete normally, and StreamerInput.signal
cancels subscriptions. End hooks run after in-flight publishes settle. Application
shutdown also cancels extension-owned streams and consumer subscriptions.
Class and method guards both apply. Shared guard evaluation awaits promised requirements and predicate results, supports Observable predicates, and denies missing identity, mismatches, empty predicates, and failed evaluation.
Based on 4.0.0 release source (4.0.0).