Esempio n. 1
0
 public IDisposable Observe(IEventObserver <TEvent, TContext, TModel> observer)
 {
     lock (_gate)
     {
         _observers.Add(observer);
     }
     _observationRegistrar.IncrementRegistration <TEvent>();
     return(EspDisposable.Create(() =>
     {
         lock (_gate)
         {
             _observers.Remove(observer);
         }
         _observationRegistrar.DecrementRegistration <TEvent>();
     }));
 }
Esempio n. 2
0
 public IDisposable Observe(IModelObserver <T> observer)
 {
     lock (_gate)
     {
         _observers.Add(observer);
     }
     if (_lastValueSet)
     {
         observer.OnNext(_lastValue);
     }
     return(EspDisposable.Create(() =>
     {
         lock (_gate)
         {
             _observers.Remove(observer);
         }
     }));
 }
Esempio n. 3
0
        public static IEventObservable <TEvent, TContext, TModel> Create <TEvent, TContext, TModel>(Func <IEventObserver <TEvent, TContext, TModel>, Action> subscribe)
        {
            Func <IEventObserver <TEvent, TContext, TModel>, IDisposable> subscribe1 = o => EspDisposable.Create(subscribe(o));

            return(new EventObservable <TEvent, TContext, TModel>(subscribe1));
        }