RxJS Demo - Tuong-Nguyen/Angular-D3-Cometd GitHub Wiki

Description

Create a page allows user getting data by clicking on a button. If the retrieving is fail, retry with a strategy.

Implementation

index.html

There are a button and and output div

loader.ts

retryStrategy function

It is a notifier that has 2 parameters

  • attempts: retry times
  • delay: time to delay between each retry

load function

  • Use XMLHttpRequest class to load .json file
  • Return value is an observable

retry method

If a source observable emits an error, resubscribe to it in the hopes that it will complete without error.

retry method

retryWhen(notifier) method

Decides whether or not to resubscribe to and mirror the source observable by passing a Throwable from the onError notification to a function that generates a second Observable.

retryWhen method

main.ts

  • renderMovies: render movies object to html elements
  • Transform emitting item from load observable to click observable

Source code

https://github.com/Tuong-Nguyen/Angular-D3-Cometd/tree/master/RxJSDemo