import { Component } from '@angular/core' ; import { HttpClient } from '@angular/common/http' ; import { map } from 'rxjs/operators' ; import { keepFresh , shareAndCache , retryExponentialBackoff } from '../../operators/' ; export interface GitHubSearch { items : { name : string ; description : string ; } [ ] ; } @ Component ( { selector : 'app-root' , templateUrl : './app.component.html' , styleUrls : [ './app.component.css' ] , } ) export class AppComponent { title = 'app' ; repos ; constructor ( http ) { const path = 'https://zapi.github.com/search/repositories?q=angular' ; this . repos = http . get < GitHubSearch > ( path ) . pipe ( map ( results => results . items ) , retryExponentialBackoff ( 5 , 1000 ) , keepFresh ( 1000 * 60 * 5 ) , shareAndCache ( 'repos' ) ) ; } }