Header menu logo FCQRS

ISubscribe<'TDataEvent> Type

Instance members

Instance member Description

this.Subscribe

Full Usage: this.Subscribe

Parameters:
    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 - Optional callback function to handle the event (defaults to ignoring the event if not provided).
    ?cancellationToken : CancellationToken - An optional cancellation token to cancel the subscription.

Returns: IAwaitableDisposable
Modifiers: abstract

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.

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

Optional callback function to handle the event (defaults to ignoring the event if not provided).

?cancellationToken : CancellationToken

An optional cancellation token to cancel the subscription.

Returns: IAwaitableDisposable
Example

 // 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
val async: AsyncBuilder
val targetId: (obj -> obj)
val id: x: 'T -> 'T
val subscription: 'a
val query: Linq.QueryBuilder
Multiple items
type Async = static member AsBeginEnd: computation: ('Arg -> Async<'T>) -> ('Arg * AsyncCallback * obj -> IAsyncResult) * (IAsyncResult -> 'T) * (IAsyncResult -> unit) static member AwaitEvent: event: IEvent<'Del,'T> * ?cancelAction: (unit -> unit) -> Async<'T> (requires delegate and 'Del :> Delegate) static member AwaitIAsyncResult: iar: IAsyncResult * ?millisecondsTimeout: int -> Async<bool> static member AwaitTask: task: Task<'T> -> Async<'T> + 1 overload static member AwaitWaitHandle: waitHandle: WaitHandle * ?millisecondsTimeout: int -> Async<bool> static member CancelDefaultToken: unit -> unit static member Catch: computation: Async<'T> -> Async<Choice<'T,exn>> static member Choice: computations: Async<'T option> seq -> Async<'T option> static member FromBeginEnd: beginAction: (AsyncCallback * obj -> IAsyncResult) * endAction: (IAsyncResult -> 'T) * ?cancelAction: (unit -> unit) -> Async<'T> + 3 overloads static member FromContinuations: callback: (('T -> unit) * (exn -> unit) * (OperationCanceledException -> unit) -> unit) -> Async<'T> ...

--------------------
type Async<'T>
static member Async.Start: computation: Async<unit> * ?cancellationToken: System.Threading.CancellationToken -> unit

this.Subscribe

Full Usage: this.Subscribe

Parameters:
    callback : 'TDataEvent -> unit - Function invoked for each event, e.g. printing or processing the event.
    ?cancellationToken : CancellationToken - An optional cancellation token to cancel the subscription.

Returns: IDisposable
Modifiers: abstract

Subscribes to all events and invokes the specified callback for each event.

callback : 'TDataEvent -> unit

Function invoked for each event, e.g. printing or processing the event.

?cancellationToken : CancellationToken

An optional cancellation token to cancel the subscription.

Returns: IDisposable
Example

 // 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()
val subscription: obj
val query: Linq.QueryBuilder
val printfn: format: Printf.TextWriterFormat<'T> -> 'T

Type something to start searching.