private IObservable <Common.Container> FetchContainer(HttpClient httpClient) { return(Observable.Create <Common.Container>( async observer => { try { _eventBus.Publish(new Event.Data.Fetching()); var result = await httpClient.GetAsync(Uri).ConfigureAwait(false); result.EnsureSuccessStatusCode(); var stream = await result.Content.ReadAsStreamAsync().ConfigureAwait(false); var container = await Common.Serializer.Deserialize(stream).ConfigureAwait(false); _eventBus.Publish(new Event.Data.Available(container)); observer.OnNext(container); observer.OnCompleted(); } catch (Exception e) { observer.OnError(e); } })); }
public IObservable <ITransition> Enter() { return(Observable.Create <ITransition>( observer => { _eventBus.Publish(new Event.Application.Suspended()); return _eventBus .GetEvent <Event.Application.Resuming>() .Select(_ => new Transition.ToResuming(_aggregateRoot)) .Subscribe(observer); })); }