UNPKG

wonka

Version:

A fast push & pull stream library for Reason, loosely following the [callbag spec](https://github.com/callbag/callbag)

53 lines (46 loc) 1.39 kB
import * as Curry from "bs-platform/lib/es6/curry.js"; import * as Wonka_helpers from "../wonka_helpers.js"; function subscribe(f) { return (function (source) { var state = /* record */[ /* talkback */Wonka_helpers.talkbackPlaceholder, /* ended */false ]; Curry._1(source, (function (signal) { if (typeof signal === "number") { state[/* ended */1] = true; return /* () */0; } else if (signal.tag) { if (state[/* ended */1]) { return /* () */0; } else { f(signal[0]); return state[/* talkback */0](/* Pull */0); } } else { var x = signal[0]; state[/* talkback */0] = x; return x(/* Pull */0); } })); return /* record */[/* unsubscribe */(function (param) { if (state[/* ended */1]) { return 0; } else { state[/* ended */1] = true; return state[/* talkback */0](/* Close */1); } })]; }); } function forEach(f) { return (function (source) { subscribe(f)(source); return /* () */0; }); } export { subscribe , forEach , } /* No side effect */