619
*/
620
export function chain<T, R>(event: Event<T>, sythensize: ($: IChainableSythensis<T>) => IChainableSythensis<R>): Event<R> {
621
>
const fn: Event<R> = (listener, thisArgs, disposables) => {
event.ts
622
>
const cs = sythensize(new ChainableSynthesis()) as ChainableSynthesis;
623
>
return event(function (value) {
624
>
const result = cs.evaluate(value);
625
>
if (result !== HaltChainable) {
626
>
listener.call(thisArgs, result);
627
>
}
628
>
}, undefined, disposables);
629
>
};
630
>
631
>
return fn;
632
>
}
633
634
const HaltChainable = Symbol('HaltChainable');
635
636
class ChainableSynthesis implements IChainableSythensis<any> {
637
>
private readonly steps: ((input: any) => unknown)[] = [];
event.ts
638
639
map<O>(fn: (i: any) => O): this {