private IObservable <INode> Fetcher(Guid id)
 {
     return(Observable.Defer(() =>
     {
         INode node;
         return NodeCache.TryGetValue(id, out node)
                 ? Observable.Return(node)
                 : _lazyStorage.Value.Fetch(id).Do(x => NodeCache[id] = x);
     }));
 }
Beispiel #2
0
 public IObservable <INode> Fetch(IObservable <Guid> ids)
 {
     return(Observable
            .CreateWithDisposable <INode>(observer =>
                                          ids.Subscribe(x =>
     {
         INode node;
         if (NodeCache.TryGetValue(x, out node))
         {
             observer.OnNext(node);
         }
         else
         {
             node = _lazyStorage.Value.Fetch(x);
             NodeCache[x] = node;
             observer.OnNext(node);
         }
     }, observer.OnError, observer.OnCompleted)));
 }