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

Fix make source not being sync-safe

When the observer was called synchronously the
Start event wasn't yet sent to the Sink which
caused events to be missed. This swaps the order
of the call for safety.

Changed files
+7 -5
src
+7 -5
src/sources/wonka_source_make.re
···
open Wonka_types;
let make = f => curry(sink => {
-
let teardown = f(.{
-
next: value => sink(.Push(value)),
-
complete: () => sink(.End)
-
});
+
let teardown = ref((.) => ());
sink(.Start((.signal) => {
switch (signal) {
-
| Close => teardown(.)
+
| Close => teardown^(.)
| Pull => ()
}
}));
+
+
teardown := f(.{
+
next: value => sink(.Push(value)),
+
complete: () => sink(.End)
+
});
});