ISubscribe<'TDataEvent>Type

PackageFCQRS

Specification

Kind
Type
Members
4
Examples
0
SubscribeSignature
this.Subscribe
SubscribeSignature
this.Subscribe
SubscribeSignature
this.Subscribe
SubscribeSignature
this.Subscribe

Summary

NameSignatureSynopsis
Subscribethis.SubscribeSubscribes to events matching a specific correlation ID and an additional filter.
Subscribethis.SubscribeSubscribes to events matching a specific correlation ID.
Subscribethis.SubscribeSubscribes to events using a filter.
Subscribethis.SubscribeSubscribes to all events and invokes the specified callback for each event.

Subscribe

this.Subscribe
Member
Subscribes to events matching a specific correlation ID and an additional filter.

Parameters

NameTypeDescription
cidCIDThe correlation ID to match.
filter'TDataEvent -> boolAdditional predicate to filter events after CID matching.
takeintMaximum number of events to process.
callback'TDataEvent -> unit
cancellationTokenCancellationToken

Returns

IAwaitableDisposable

Subscribe

this.Subscribe
Member
Subscribes to events matching a specific correlation ID.

Parameters

NameTypeDescription
cidCIDThe correlation ID to match.
takeintMaximum number of events to process.
callback'TDataEvent -> unit
cancellationTokenCancellationToken

Returns

IAwaitableDisposable

Subscribe

this.Subscribe
Member
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

NameTypeDescription
filter'TDataEvent -> bool Predicate function to determine if an event should be processed. To wait for a correlation ID, use the Subscribe(cid, take) overload instead: it is routed by correlation ID, and a transactional projection delivers to it only after the events that caused the notification are committed.
takeintMaximum number of events to process.
callback'TDataEvent -> unit
cancellationTokenCancellationToken

Returns

IAwaitableDisposable

Verification Examples

// Wait for the first notification that matches a predicate. The callback and
// cancellation token are optional.
async {
    use subscription = query.Subscribe((fun event -> isPublication event), 1)
    do! subscription.Task |> Async.AwaitTask
} |> Async.Start

Subscribe

this.Subscribe
Member
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

NameTypeDescription
callback'TDataEvent -> unitFunction invoked for each event, e.g. printing or processing the event.
cancellationTokenCancellationToken

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()