Mirror: 🎩 A tiny but capable push & pull stream library for TypeScript and Flow
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Replace tapAll with separate onStart, onPush, onEnd

+67 -60
+3
src/operators/wonka_operator_onEnd.d.ts
··· 1 + import { Operator } from '../wonka_types'; 2 + 3 + export const onEnd: <A>(f: (value: A) => void) => Operator<A, A>;
+28
src/operators/wonka_operator_onEnd.re
··· 1 + open Wonka_types; 2 + 3 + let onEnd = f => curry(source => curry(sink => { 4 + let ended = ref(false); 5 + 6 + source((.signal) => { 7 + switch (signal) { 8 + | Start(talkback) => { 9 + sink(.Start((.signal) => { 10 + talkback(.signal); 11 + 12 + if (!ended^) { 13 + ended := true; 14 + f(.); 15 + } 16 + })); 17 + } 18 + | End => { 19 + if (!ended^) { 20 + ended := true; 21 + sink(.signal); 22 + f(.); 23 + } 24 + } 25 + | _ => sink(.signal) 26 + }; 27 + }); 28 + }));
+3
src/operators/wonka_operator_onEnd.rei
··· 1 + open Wonka_types; 2 + 3 + let onEnd: ((.unit) => unit, sourceT('a), sinkT('a)) => unit;
+4
src/operators/wonka_operator_onPush.rei
··· 1 + open Wonka_types; 2 + 3 + let onPush: ((.'a) => unit, sourceT('a), sinkT('a)) => unit; 4 + let tap: ((.'a) => unit, sourceT('a), sinkT('a)) => unit;
+3
src/operators/wonka_operator_onStart.d.ts
··· 1 + import { Operator } from '../wonka_types'; 2 + 3 + export const onStart: <A>(f: (value: A) => void) => Operator<A, A>;
+13
src/operators/wonka_operator_onStart.re
··· 1 + open Wonka_types; 2 + 3 + let onStart = f => curry(source => curry(sink => { 4 + source((.signal) => { 5 + switch (signal) { 6 + | Start(_) => { 7 + sink(.signal); 8 + f(.); 9 + } 10 + | _ => sink(.signal) 11 + }; 12 + }); 13 + }));
+3
src/operators/wonka_operator_onStart.rei
··· 1 + open Wonka_types; 2 + 3 + let onStart: ((.unit) => unit, sourceT('a), sinkT('a)) => unit;
+1
src/operators/wonka_operator_tap.d.ts src/operators/wonka_operator_onPush.d.ts
··· 1 1 import { Operator } from '../wonka_types'; 2 2 3 + export const onPush: <A>(f: (value: A) => void) => Operator<A, A>; 3 4 export const tap: <A>(f: (value: A) => void) => Operator<A, A>;
+3 -1
src/operators/wonka_operator_tap.re src/operators/wonka_operator_onPush.re
··· 1 1 open Wonka_types; 2 2 3 - let tap = f => curry(source => curry(sink => { 3 + let onPush = f => curry(source => curry(sink => { 4 4 source((.signal) => { 5 5 switch (signal) { 6 6 | Push(x) => f(.x) ··· 10 10 sink(.signal); 11 11 }); 12 12 })); 13 + 14 + let tap = onPush;
-3
src/operators/wonka_operator_tap.rei
··· 1 - open Wonka_types; 2 - 3 - let tap: ((.'a) => unit, sourceT('a), sinkT('a)) => unit;
-7
src/operators/wonka_operator_tapAll.d.ts
··· 1 - import { Operator } from '../wonka_types'; 2 - 3 - export const tapAll: <A>( 4 - onStart: () => void, 5 - onPush: (value: A) => void, 6 - onEnd: () => void 7 - ) => Operator<A, A>;
-36
src/operators/wonka_operator_tapAll.re
··· 1 - open Wonka_types; 2 - 3 - let tapAll = (~onStart, ~onPush, ~onEnd) => { 4 - curry(source => curry(sink => { 5 - let ended = ref(false); 6 - 7 - source((.signal) => { 8 - switch (signal) { 9 - | Start(talkback) => { 10 - onStart(.) 11 - 12 - sink(.Start((.signal) => { 13 - switch (signal) { 14 - | Close when !ended^ => { 15 - ended := true; 16 - onEnd(.); 17 - } 18 - | Close => () 19 - | _ => talkback(.signal) 20 - } 21 - })); 22 - } 23 - | Push(x) => { 24 - onPush(.x) 25 - sink(.signal); 26 - } 27 - | End when !ended^ => { 28 - ended := true; 29 - onEnd(.) 30 - } 31 - | _ => () 32 - }; 33 - 34 - }); 35 - })); 36 - };
-9
src/operators/wonka_operator_tapAll.rei
··· 1 - open Wonka_types; 2 - 3 - let tapAll: ( 4 - ~onStart: (.unit) => unit, 5 - ~onPush: (.'a) => unit, 6 - ~onEnd: (.unit) => unit, 7 - sourceT('a), 8 - sinkT('a) 9 - ) => unit;
+3 -2
src/wonka.d.ts
··· 12 12 export * from './operators/wonka_operator_filter'; 13 13 export * from './operators/wonka_operator_map'; 14 14 export * from './operators/wonka_operator_mergeMap'; 15 + export * from './operators/wonka_operator_onEnd'; 16 + export * from './operators/wonka_operator_onPush'; 17 + export * from './operators/wonka_operator_onStart'; 15 18 export * from './operators/wonka_operator_scan'; 16 19 export * from './operators/wonka_operator_share'; 17 20 export * from './operators/wonka_operator_skip'; ··· 22 25 export * from './operators/wonka_operator_takeLast'; 23 26 export * from './operators/wonka_operator_takeUntil'; 24 27 export * from './operators/wonka_operator_takeWhile'; 25 - export * from './operators/wonka_operator_tap'; 26 - export * from './operators/wonka_operator_tapAll'; 27 28 28 29 /* sinks */ 29 30 export * from './sinks/wonka_sink_publish';
+3 -2
src/wonka.ml
··· 14 14 include Wonka_operator_filter 15 15 include Wonka_operator_map 16 16 include Wonka_operator_mergeMap 17 + include Wonka_operator_onEnd 18 + include Wonka_operator_onPush 19 + include Wonka_operator_onStart 17 20 include Wonka_operator_scan 18 21 include Wonka_operator_share 19 22 include Wonka_operator_skip ··· 24 27 include Wonka_operator_takeLast 25 28 include Wonka_operator_takeUntil 26 29 include Wonka_operator_takeWhile 27 - include Wonka_operator_tap 28 - include Wonka_operator_tapAll 29 30 30 31 (* sinks *) 31 32 include Wonka_sink_publish