import { defer , Observable } from 'rxjs' ; import { delay } from 'rxjs/operators' ; export function asyncError < T > ( error , delayTime = 0 ) { return defer ( ( ) => Promise . reject ( error ) ) . pipe ( delay ( delayTime ) ) ; }