예제 #1
0
        public IDisposable RegisterNotificationHandler <TNotification>(Action <TNotification> handler)
            where TNotification : INotification
        {
            var subscription = _asyncMessageBus.Subscribe(handler);

            return(SubscriptionTracker <TNotification> .Track(subscription));
        }
예제 #2
0
        public IDisposable RegisterRequestHandler <TRequest>(Action <TRequest> handler)
            where TRequest : IRequest
        {
            SubscriptionTracker <TRequest> .ThrowIfHasSubscribers();

            var subscription = _asyncMessageBus.Subscribe(handler);

            return(SubscriptionTracker <TRequest> .Track(subscription));
        }
예제 #3
0
        public IDisposable RegisterRequestHandler <TRequest>(
            Func <TRequest, CancellationToken, UniTask> handler,
            CancellationToken cancellationToken = default)
            where TRequest : IAsyncRequest
        {
            SubscriptionTracker <TRequest> .ThrowIfHasSubscribers();

            var subscription = _asyncMessageBus.Subscribe <TRequest>(
                (msg, cancellationToken2) => Handle(handler, msg, cancellationToken, cancellationToken2)
                );

            return(SubscriptionTracker <TRequest> .Track(subscription));
        }