import { interval } from 'rxjs' ; import { take } from 'rxjs/operators' ; const period = 1000 ; const poll$ = interval ( period ) ; poll$ . pipe ( take ( 4 ) ) . subscribe ( { next : ( x ) => console . log ( `Delayed by ${ period }ms item: ${ x }` ) , complete : ( ) => console . log ( 'Delayed complete!' ) } ) ;