Exemple #1
0
        public static IDisposable Subscribe <T>(this IClientObservable observable, Action <T> callback)
        {
            Requires.NotNull(callback, nameof(callback));

            return(observable.Subscribe(new DelegateObserver(x => callback((T)x))));
        }
Exemple #2
0
        /// <summary>
        /// Subscribe a consumer to this stream reference using strongly-typed delegate.
        /// </summary>
        /// <typeparam name="T">The type of the items produced by the stream.</typeparam>
        /// <param name="callback">Strongly-typed version of callback delegate.</param>
        /// <returns>
        /// A promise for a StreamSubscription that represents the subscription.
        /// The consumer may unsubscribe by using this object.
        /// The subscription remains active for as long as it is not explicitely unsubscribed.
        /// </returns>
        public virtual Task <StreamSubscription> Subscribe <T>(Func <T, Task> callback)
        {
            Requires.NotNull(callback, nameof(callback));

            return(Subscribe(item => callback((T)item)));
        }
Exemple #3
0
        /// <summary>
        /// Notifies the provider that an observer is to receive notifications.
        /// </summary>
        /// <returns>
        /// A reference to an interface that allows observers to stop receiving notifications before the provider has finished sending them.
        /// </returns>
        /// <param name="client">The instance of client observable proxy</param>
        /// <param name="callback">The callback delegate that is to receive notifications</param>
        public static IDisposable Subscribe(this Observer client, Action <Notification> callback)
        {
            Requires.NotNull(callback, "callback");

            return(client.Subscribe(new DelegateObserver(callback)));
        }
Exemple #4
0
        public virtual async Task <TResult> Ask <TResult>(object message)
        {
            Requires.NotNull(message, nameof(message));

            return((TResult)await middleware.Receive(Path, message, endpoint.ReceiveAsk));
        }