import { Observable , from } from 'rxjs' ; export function isObservable < T = any > ( val ) { return val instanceof Observable ; } export function handleObservable ( resolver ) { return ( ... args ) => { let result ; try { result = resolver ( ... args ) ; } catch ( e ) { return Promise . reject ( e ) ; } return result instanceof Promise || isObservable ( result ) ? from ( result ) . toPromise ( ) : Promise . resolve ( result ) ; } ; }