ISubscribe<'TDataEvent>Type
PackageFCQRS
Specification
Kind
Type
Members
4
Examples
0
SubscribeSignature
this.Subscribe
SubscribeSignature
this.Subscribe
SubscribeSignature
this.Subscribe
SubscribeSignature
this.Subscribe
Summary
| Name | Signature | Synopsis |
|---|---|---|
| Subscribe | this.Subscribe | Subscribes to events matching a specific correlation ID and an additional filter. |
| Subscribe | this.Subscribe | Subscribes to events matching a specific correlation ID. |
| Subscribe | this.Subscribe | Subscribes to events using a filter. |
| Subscribe | this.Subscribe | Subscribes to all events and invokes the specified callback for each event. |
Subscribes to events matching a specific correlation ID and an additional filter.
Parameters
| Name | Type | Description |
|---|---|---|
| cid | CID | The correlation ID to match. |
| filter | 'TDataEvent -> bool | Additional predicate to filter events after CID matching. |
| take | int | Maximum number of events to process. |
| callback | 'TDataEvent -> unit | |
| cancellationToken | CancellationToken |
Returns
IAwaitableDisposable
Subscribes to events matching a specific correlation ID.
Parameters
| Name | Type | Description |
|---|---|---|
| cid | CID | The correlation ID to match. |
| take | int | Maximum number of events to process. |
| callback | 'TDataEvent -> unit | |
| cancellationToken | CancellationToken |
Returns
IAwaitableDisposable
Subscribes to events using a filter. Only events for which the predicate returns true
are processed, and the callback is invoked for each matching event up to a specified count.
Registration is complete when this method returns. The Task succeeds only
after that count is reached; cancellation or disposal before then cancels it.
Parameters
| Name | Type | Description |
|---|---|---|
| filter | 'TDataEvent -> bool |
Predicate function to determine if an event should be processed, e.g.
fun event -> event.CorrelationId = targetId.
|
| take | int | Maximum number of events to process. |
| callback | 'TDataEvent -> unit | |
| cancellationToken | CancellationToken |
Returns
IAwaitableDisposable
Verification Examples
// Typical usage: subscribe for a filtered event by matching on CorrelationId,
// process only one event, and omit the callback and cancellation token.
async {
let targetId = some-correlation-id
// Here, take is set to 1 and no callback or cancellation token is provided.
let! subscription = query.Subscribe((fun event -> event.CorrelationId = targetId), 1)
// Use the asynchronous subscription as needed.
} |> Async.Start
Subscribes to all events and invokes the specified callback for each event.
Registration is complete when this method returns. Callbacks run in order
on a separate worker; a full subscriber queue drops its oldest notification.
Parameters
| Name | Type | Description |
|---|---|---|
| callback | 'TDataEvent -> unit | Function invoked for each event, e.g. printing or processing the event. |
| cancellationToken | CancellationToken |
Returns
IDisposable
Verification Examples
// Example usage: subscribe to all events and write them to the console.
let subscription =
query.Subscribe((fun event -> printfn "Received event: %A" event))
// Later, to cancel the subscription:
subscription.Dispose()