public IObservable <DictionaryNotification <TKey, TValue> > Get(TKey key)
 {
     return(Observable.Create <DictionaryNotification <TKey, TValue> >(observer =>
     {
         TValue existingValue;
         if (_state.TryGetValue(key, out existingValue))
         {
             observer.OnNext(DictionaryNotification.Existing(key, existingValue));
         }
         else
         {
             observer.OnNext(DictionaryNotification.Missing <TKey, TValue>(key));
         }
         return new CompositeDisposable(_subject
                                        .Where(dn => dn.Type == DictionaryNotificationType.KeyCleared || Equals(dn.Key, key))
                                        .Subscribe(observer), Connect());
     })
            .SubscribeOn(_scheduler));
 }
예제 #2
0
 public IObservable <DictionaryNotification <TKey, TValue> > Get(TKey key)
 {
     return(Observable.Create <DictionaryNotification <TKey, TValue> >(observer =>
     {
         lock (_lock)
         {
             TValue existingValue;
             if (_state.TryGetValue(key, out existingValue))
             {
                 observer.OnNext(DictionaryNotification.Existing(key, existingValue));
             }
             else
             {
                 observer.OnNext(DictionaryNotification.Missing <TKey, TValue>(key));
             }
             return new CompositeDisposable(_subject.Subscribe(observer), Connect());
         }
     }));
 }