public IRequestProgressObservable <TItem, TResult> MonitorUntil <TItem, TResult>( IPartialItemRequest <TResult, TItem> request, Func <TItem, TResult, TResult> factory, CancellationToken cancellationToken ) { request.SetPartialResultToken(); if (_activeObservables.TryGetValue(request.PartialResultToken !, out var o) && o is IRequestProgressObservable <TItem, TResult> observable) { return(observable); } observable = new RequestProgressObservable <TItem, TResult>( _serializer, request.PartialResultToken, MakeRequest(request), factory, cancellationToken, () => _activeObservables.TryRemove(request.PartialResultToken, out _) ); _activeObservables.TryAdd(request.PartialResultToken, observable); return(observable); }
public IRequestProgressObservable <TItem, TResult> MonitorUntil <TItem, TResult>( IPartialItemRequest <TResult, TItem> request, Func <TItem, TResult> factory, CancellationToken cancellationToken ) { request.SetPartialResultToken(); if (_activeObservables.TryGetValue(request.PartialResultToken !, out var o) && o is IRequestProgressObservable <TItem, TResult> observable) { return(observable); } observable = new PartialItemRequestProgressObservable <TItem, TResult>( _serializer, request.PartialResultToken !, MakeRequest(request), (x, _) => factory(x), _ => default !,