import { Observable } from 'rxjs' ; import { filter } from 'rxjs/operators' ; export function obOutsideFilter ( ... elements ) { return source$ => source$ . pipe ( filter ( event => ! ( event . target instanceof Node ) || elements . reduce ( ( isOutside , element ) => isOutside && ! element . contains ( event . target as Node ) , true ) ) ) ; }