UNPKG

@terminus/ngx-tools

Version:

[![CircleCI][circle-badge]][circle-link] [![codecov][codecov-badge]][codecov-project] [![semantic-release][semantic-release-badge]][semantic-release] [![MIT License][license-image]][license-url] <br> [![NPM version][npm-version-image]][npm-url] [![Github

27 lines (26 loc) 869 B
import { Observable } from 'rxjs'; /** * An interface that requires ngOnDestroy */ export interface WithOnDestroy { ngOnDestroy(): void; componentDestroyed$?: Observable<true>; [key: string]: any; } /** * Patch the component with unsubscribe behavior * * @param component - The component class (`this` context) * @returns An observable representing the unsubscribe event */ export declare function componentDestroyed(component: WithOnDestroy): Observable<true>; /** * A pipe-able operator to unsubscribe during OnDestroy lifecycle event * * @param component - The component class (`this` context) * @returns The component wrapped in an Observable * * @example * source.pipe(untilComponentDestroyed(this)).subscribe... */ export declare const untilComponentDestroyed: <T>(component: WithOnDestroy) => (source: Observable<T>) => Observable<T>;