Пример #1
0
        public static UniTask <TMessage> FirstAsync <TKey, TMessage>(this ISubscriber <TKey, TMessage> subscriber, TKey key, CancellationToken cancellationToken, Func <TMessage, bool> predicate, params MessageHandlerFilter <TMessage>[] filters)

        {
            var predicateFilter = new PredicateFilter <TMessage>(predicate);

            filters = (filters.Length == 0)
                ? new[] { predicateFilter }
                : ArrayUtil.ImmutableAdd(filters, predicateFilter);

            return(new UniTask <TMessage>(new FirstAsyncMessageHandler <TKey, TMessage>(subscriber, key, cancellationToken, filters), 0));
        }
Пример #2
0
        public static IDisposable Subscribe <TKey, TMessage>(this ISubscriber <TKey, TMessage> subscriber, TKey key, Action <TMessage> handler, Func <TMessage, bool> predicate, params MessageHandlerFilter <TMessage>[] filters)

        {
            var predicateFilter = new PredicateFilter <TMessage>(predicate);

            filters = (filters.Length == 0)
                ? new[] { predicateFilter }
                : ArrayUtil.ImmutableAdd(filters, predicateFilter);

            return(subscriber.Subscribe(key, new AnonymousMessageHandler <TMessage>(handler), filters));
        }