import { HttpError , HttpRequestConfig , HttpResponse } from "./http" ; export interface InterceptorHandlers < T > { fulfilled : ( config : T ) => void ; rejected : ( error : HttpError ) => void ; } export default class InterceptorManager < T > { handlers : InterceptorHandlers < T > [ ] = [ ] ; use ( onFulfilled ? , onRejected ? ) { this . handlers . push ( { fulfilled : onFulfilled , rejected : onRejected , } ) ; return this . handlers . length - 1 ; } eject ( id ) { if ( this . handlers [ id ] ) { this . handlers [ id ] = null ; } } forEach ( fn ) { this . handlers . forEach ( ( handler ) => { if ( handler !== null ) { fn ( handler ) ; } } ) ; } }