Пример #1
0
        private void GetBooks()
        {
            State = AsyncState.ProcessingWaitingForData;

            _getBooksSubscription.Disposable = _booksService.GetAllBooks(_getBooksScts.NextToken)
                                               .SubscribeOn(_schedulerProvider.Background)
                                               .ObserveOn(_schedulerProvider.Foreground)
                                               .Subscribe(
                books =>
            {
                State = AsyncState.Processing;
                PopulateBooks(books);
            },
                ex => State = AsyncState.Faulted(ex is ApiException ? ex.Message : "Unknown error happened"),
                () => State = AsyncState.Idle);
        }
Пример #2
0
        private void GetBookDetails(string id)
        {
            SetPlaceholders();

            State = AsyncState.ProcessingWaitingForData;

            _getBookSubscription.Disposable = _booksService.GetBook(id, _getbBookScts.NextToken)
                                              .SubscribeOn(_schedulerProvider.Background)
                                              .ObserveOn(_schedulerProvider.Foreground)
                                              .Subscribe(
                book =>
            {
                State = AsyncState.Processing;
                PopulateBookInfo(book);
            },
                ex => State = AsyncState.Faulted(ex is ApiException ? ex.Message : "Unknown error happened"),
                async() =>
            {
                await DownloadImage();
                State = AsyncState.Idle;
            });
        }