import { Subject } from "rxjs"; import { mixins } from "./internals/apply-mixins"; import { Callable } from "./internals/callable"; export declare type NextFn = (next: T) => void; export interface InvokeSubject extends Subject { (next: T): void; (...next: T extends Array ? T : never[]): void; } /** * A subject that implements both `Subject` and `Function` interfaces. Using this subject in place of a normal * method turns all invocations of that method into an observable stream without needing to modify the source of * the caller. When called with multiple arguments it will emit the arguments as an array. * * @usageNotes * * Basic usage * * ```ts * const subject = new InvokeSubject() // single argument * const subject2 = new InvokeSubject<[string, number]>() // multiple arguments * * subject("message") * subject2("message", 42) * * // with custom invoke function * const subject3 = new InvokeSubject(function () { * subject3.next("message") // call "next" to emit value * }) * ``` * * Convert `@HostListener` and `(event)` bindings into observable streams * * ```ts * @Component({ * template: `` * }) * export class MyComponent implements OnDestroy { * @HostListener("click", ["$event"]) * readonly hostClick = new InvokeSubject() * readonly inputChanges = new InvokeSubject() * * constructor() { * hostClick.subscribe(event => console.log(event)) * inputChanges.subscribe(event => console.log(event)) * } * } * ``` * * @publicApi */ export declare class InvokeSubject extends Callable> { private static [mixins]; /** * Creates a new `InvokeSubject` instance * * @param nextFn A function to be called when the subject is invoked * */ constructor(nextFn?: NextFn); }