Example #1
0
 /// <summary>
 /// 已经学习
 /// </summary>
 /// <param name="source">Source.</param>
 /// <param name="predicate">Predicate.</param>
 /// <typeparam name="T">The 1st type parameter.</typeparam>
 public static IObservable <T> Where <T>(this IObservable <T> previousObservable, Func <T, bool> predicate)
 {
     return(AnonymousObservable.Create <T>(nextObserver =>                     //看上去不一样 神经病啊 明明一样 为什么要这么写?
     {
         return previousObservable.Subscribe(AnonymousObserver.Create <T>(x => //关键字 同样是 新的观察者
         {                                                                     //也就是说对这个obs注册的观察者 自动转换成一个新的观察者 !!!
             if (predicate(x))
             {
                 nextObserver.OnNext(x);
             }
         }, nextObserver.OnError, nextObserver.OnCompleted));
     }));
 }
Example #2
0
 public static IDisposable Subscribe <T>(this IObservable <T> source, Action <T> onNext, Action <Exception> onError, Action onCompleted)
 {
     return(source.Subscribe(AnonymousObserver.Create(onNext, onError, onCompleted)));
 }
Example #3
0
 public static IDisposable Subscribe <T>(this IObservable <T> source)
 {
     return(source.Subscribe(AnonymousObserver.Create <T>(_ => { }, _ => { }, () => { })));
 }
Example #4
0
 public static IDisposable Subscribe <T>(this IObservable <T> source, Action <T> onNext)
 {
     return(source.Subscribe(AnonymousObserver.Create(onNext, _ => { }, () => { })));
 }
Example #5
0
 public IDisposable Subscirbe(Action <Msg> msgHandler)
 {
     return(mMsgDispather.Subscribe(AnonymousObserver.Create <Msg>(msgHandler, e => { }, () => { })));//注册需要observer
 }