/// <summary> /// Creates an observer from a notification callback. /// </summary> /// <param name="handler">Action that handles a notification.</param> /// <returns>The observer object that invokes the specified handler using a notification corresponding to each message it receives.</returns> public static IObserver <T> ToObserver <T>(this Action <Notification <T> > handler) { if (handler == null) { throw new ArgumentNullException("handler"); } return(new AnonymousObserver <T>( x => handler(Notification.CreateOnNext <T>(x)), exception => handler(Notification.CreateOnError <T>(exception)), () => handler(Notification.CreateOnCompleted <T>()))); }
internal void OnCompleted() { if (!stopped) { elements.Add(Notification.CreateOnCompleted <T>()); Terminated(); // Calling OnCompleted can modify the collection so we must iterate a copy. var currentSubscriptions = subscriptions.ToArray(); foreach (var subscription in currentSubscriptions) { Contract.Assume(subscription != null); var observer = subscription.Observer; subscription.Dispose(); observer.OnCompleted(); } } }
public void OnCompleted() { yield(Notification.CreateOnCompleted <T>()); dispose(); }
public void OnCompleted() { handler(Notification.CreateOnCompleted <T> ()); }