import { Observable , SchedulerLike , animationFrameScheduler } from 'rxjs' ; import * as raf from 'raf' ; raf . polyfill ( ) ; function once < T > ( value , scheduler ) { return new Observable < T > ( observer => { return scheduler . schedule ( ( ) => { observer . next ( value ) ; observer . complete ( ) ; } ) ; } ) ; } const subscription = once ( 42 , animationFrameScheduler ) . subscribe ( { next : x => console . log ( `Next: ${ x }` ) , complete : ( ) => console . log ( `Complete!` ) } ) ;