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.

Fix switchMap and concatMap not forwarding Push before Start (#69)

* Fix switchMap and concatMap not forwarding Push before Start

This is technically incorrect, but a lot of asynchronous
sources will Push eagerly, which means Start doesn't
always get to talk first.

* Readd state.innerActive guard to switchMap

authored by

Phil Plückthun and committed by
GitHub
a66720c4 ee501651

+25 -23
+25 -23
src/Wonka_operators.re
··· 202 202 ended: false, 203 203 }; 204 204 205 - let rec applyInnerSource = innerSource => 205 + let rec applyInnerSource = innerSource => { 206 + state.innerActive = true; 206 207 innerSource((. signal) => 207 208 switch (signal) { 208 209 | Start(tb) => 209 - state.innerActive = true; 210 210 state.innerTalkback = tb; 211 211 state.innerPulled = false; 212 212 tb(. Pull); ··· 231 231 | End => () 232 232 } 233 233 ); 234 + }; 234 235 235 236 source((. signal) => 236 237 switch (signal) { ··· 822 823 ended: false, 823 824 }; 824 825 825 - let applyInnerSource = innerSource => 826 + let applyInnerSource = innerSource => { 827 + state.innerActive = true; 826 828 innerSource((. signal) => 827 - switch (signal) { 828 - | Start(tb) => 829 - state.innerActive = true; 830 - state.innerTalkback = tb; 831 - state.innerPulled = false; 832 - tb(. Pull); 833 - | Push(_) when state.innerActive => 834 - sink(. signal); 835 - if (!state.innerPulled) { 836 - state.innerTalkback(. Pull); 837 - } else { 829 + if (state.innerActive) { 830 + switch (signal) { 831 + | Start(tb) => 832 + state.innerTalkback = tb; 838 833 state.innerPulled = false; 839 - }; 840 - | Push(_) => () 841 - | End when state.innerActive => 842 - state.innerActive = false; 843 - if (state.ended) { 834 + tb(. Pull); 835 + | Push(_) => 844 836 sink(. signal); 845 - } else if (!state.outerPulled) { 846 - state.outerPulled = true; 847 - state.outerTalkback(. Pull); 837 + if (!state.innerPulled) { 838 + state.innerTalkback(. Pull); 839 + } else { 840 + state.innerPulled = false; 841 + }; 842 + | End => 843 + state.innerActive = false; 844 + if (state.ended) { 845 + sink(. signal); 846 + } else if (!state.outerPulled) { 847 + state.outerPulled = true; 848 + state.outerTalkback(. Pull); 849 + }; 848 850 }; 849 - | End => () 850 851 } 851 852 ); 853 + }; 852 854 853 855 source((. signal) => 854 856 switch (signal) {