public static async ValueTask <TMessage> FirstAsync <TMessage>(this IBufferedAsyncSubscriber <TMessage> subscriber, CancellationToken cancellationToken, Func <TMessage, bool> predicate, params AsyncMessageHandlerFilter <TMessage>[] filters) { var predicateFilter = new AsyncPredicateFilter <TMessage>(predicate); filters = (filters.Length == 0) ? new[] { predicateFilter } : ArrayUtil.ImmutableAdd(filters, predicateFilter); return(await new ValueTask <TMessage>(await FirstAsyncAsyncBufferedMessageHandler <TMessage> .CreateAsync(subscriber, cancellationToken, filters), 0)); }
public static ValueTask <IAsyncDisposable> SubscribeAsync <TKey, TMessage>(this IDistributedSubscriber <TKey, TMessage> subscriber, TKey key, Func <TMessage, CancellationToken, ValueTask> handler, Func <TMessage, bool> predicate, AsyncMessageHandlerFilter <TMessage>[] filters, CancellationToken cancellationToken = default) { var predicateFilter = new AsyncPredicateFilter <TMessage>(predicate); filters = (filters.Length == 0) ? new[] { predicateFilter } : Append(filters, predicateFilter); return(subscriber.SubscribeAsync(key, new AnonymousAsyncMessageHandler <TMessage>(handler), filters, cancellationToken)); }
public static IDisposable Subscribe <TMessage>(this IAsyncSubscriber <TMessage> subscriber, Func <TMessage, CancellationToken, ValueTask> handler, Func <TMessage, bool> predicate, params AsyncMessageHandlerFilter <TMessage>[] filters) { var predicateFilter = new AsyncPredicateFilter <TMessage>(predicate); filters = (filters.Length == 0) ? new[] { predicateFilter } : ArrayUtil.ImmutableAdd(filters, predicateFilter); return(subscriber.Subscribe(new AnonymousAsyncMessageHandler <TMessage>(handler), filters)); }
public static ValueTask <IDisposable> SubscribeAsync <TMessage>(this IBufferedAsyncSubscriber <TMessage> subscriber, Func <TMessage, CancellationToken, ValueTask> handler, Func <TMessage, bool> predicate, AsyncMessageHandlerFilter <TMessage>[] filters, CancellationToken cancellationToken = default) { var predicateFilter = new AsyncPredicateFilter <TMessage>(predicate); filters = (filters.Length == 0) ? new[] { predicateFilter } : ArrayUtil.ImmutableAdd(filters, predicateFilter); return(subscriber.SubscribeAsync(new AnonymousAsyncMessageHandler <TMessage>(handler), filters, cancellationToken)); }
public static UniTask <TMessage> FirstAsync <TMessage>(this IAsyncSubscriber <TMessage> subscriber, CancellationToken cancellationToken, Func <TMessage, bool> predicate, params AsyncMessageHandlerFilter <TMessage>[] filters) { var predicateFilter = new AsyncPredicateFilter <TMessage>(predicate); filters = (filters.Length == 0) ? new[] { predicateFilter } : ArrayUtil.ImmutableAdd(filters, predicateFilter); return(new UniTask <TMessage>(new FirstAsyncAsyncMessageHandler <TMessage>(subscriber, cancellationToken, filters), 0)); }