/** * @license Use of this source code is governed by an MIT-style license that * can be found in the LICENSE file at https://github.com/cartant/rxjs-etc */ import { observable, ObservableInput, OperatorFunction, Subject } from "rxjs"; export function handler(): ((value: T) => void) & ObservableInput; export function handler( operator: OperatorFunction ): ((value: T) => void) & ObservableInput; export function handler( operator?: OperatorFunction ): ((value: T) => void) & ObservableInput { const subject = new Subject(); const source = operator ? subject.pipe(operator) : subject; const next: any = (arg: T) => subject.next(arg); next[observable] = () => source; return next; }