import { NEVER, Observable, of, Subscription, throwError } from "rxjs";
import { catchError, map, takeUntil } from "rxjs/operators";

const userland = <T>(selector: (t: T) => T) => map(selector);

class Something {
    someObservable = NEVER;
    constructor() {
        const ob = of(1).pipe(
            map(value => this.map(value)),
            userland(value => this.map(value)),
            takeUntil(this.someObservable),
            catchError(error => this.catchError(error))
        ).subscribe(
            value => this.next(value),
            error => this.error(error),
            () => this.complete()
        );
        const subscription = new Subscription(() => this.tearDown);
        subscription.add(() => this.tearDown);
    }
    catchError(error: any): Observable<never> { return throwError(error); }
    complete(): void {}
    error(error: any): void {}
    map<T>(t: T): T { return t; }
    next<T>(t: T): void {}
    tearDown(): void {}
}

[no-unbound-methods]: Unbound methods are forbidden
