Preview:
// usage
loadGame(): void {
  this.games = []
  this.loadHandler.start()
  this.http.get<Game[]>.get(this.url).subscribe(
    games => {
      this.loadHandler.finish();
      this.games = games;
    })
}

// service
export class LoadHandler {
  private _isLoading$ = new BehaviorSubject(false);
  isLoading$: Observable<boolean> = this._isLoading$.pipe(
  	switchMap( isLoading => {
      if(!isLoading) {
        return of(false)
      }else{
        return of(true).pipe(delay(1000));
      }
    })
  )

  start(){
    this._isLoading.next(true);
  }
  finish(){
    this._isLoading.next(false);
  }
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter