···11open Callbag_types;
2233+/* -- source factories */
44+55+/* Accepts a list and creates a pullable source for that list.
66+ The source will emit events when being pulled until the list
77+ is exhausted and it completes */
38let fromList: (list('a), signalT('a) => unit) => unit;
99+1010+/* Accepts an array and creates a pullable source for that array.
1111+ The source will emit events when being pulled until the array
1212+ is exhausted and it completes */
413let fromArray: (array('a), signalT('a) => unit) => unit;
51466-let map: ('a => 'b, (signalT('a) => unit) => unit, signalT('b) => unit) => unit;
77-let filter: ('a => bool, (signalT('a) => unit) => unit, signalT('a) => unit) => unit;
88-let scan: (('b, 'a) => 'b, 'b, (signalT('a) => unit) => unit, signalT('b) => unit) => unit;
1515+/* -- operators */
1616+1717+/* Takes a mapping function from one type to another, and a source,
1818+ and creates a sink & source.
1919+ All values that it receives will be transformed using the mapping
2020+ function and emitted on the new source */
2121+let map:
2222+ ('a => 'b, (signalT('a) => unit) => unit, signalT('b) => unit) => unit;
2323+2424+/* Takes a predicate function returning a boolean, and a source,
2525+ and creates a sink & source.
2626+ All values that it receives will be filtered using the predicate,
2727+ and only truthy values will be passed on to the new source.
2828+ The sink will attempt to pull a new value when one was filtered. */
2929+let filter:
3030+ ('a => bool, (signalT('a) => unit) => unit, signalT('a) => unit) => unit;
3131+3232+/* Takes a reducer function, a seed value, and a source, and creates
3333+ a sink & source.
3434+ The last returned value from the reducer function (or the seed value
3535+ initially) will be passed to the reducer together with the value
3636+ that the sink receives. All return values of the reducer function
3737+ are emitted on the new source. */
3838+let scan:
3939+ (('b, 'a) => 'b, 'b, (signalT('a) => unit) => unit, signalT('b) => unit) =>
4040+ unit;
4141+4242+/* Takes an array of sources and creates a sink & source.
4343+ All values that the sink receives from all sources will be passed through
4444+ to the new source */
945let merge: (array((signalT('a) => unit) => unit), signalT('a) => unit) => unit;
4646+4747+/* Takes a listenable or a pullable source and creates a new source that
4848+ will ensure that the source is shared between all sinks that follow.
4949+ Essentially the original source will only be created once. */
1050let share: ((signalT('a) => unit) => unit, signalT('a) => unit) => unit;
1111-let combine: ((signalT('a) => unit) => unit, (signalT('b) => unit) => unit, signalT(('a, 'b)) => unit) => unit;
5151+5252+/* Takes two sources and creates a new source & sink.
5353+ All latest values from both sources will be passed through as a
5454+ tuple of the last values that have been observed */
5555+let combine:
5656+ (
5757+ (signalT('a) => unit) => unit,
5858+ (signalT('b) => unit) => unit,
5959+ signalT(('a, 'b)) => unit
6060+ ) =>
6161+ unit;
6262+6363+/* -- sink factories */
12646565+/* Takes a function and a source, and creates a sink.
6666+ The function will be called for each value that the sink receives.
6767+ The sink will attempt to pull new values as values come in, until
6868+ the source ends. */
1369let forEach: ('a => unit, (signalT('a) => unit) => unit) => unit;
1414-let subscribe: ('a => unit, (signalT('a) => unit) => unit) => (unit => unit);
7070+7171+/* Similar to the `forEach` sink factory, but returns an anonymous function
7272+ that when called will end the stream immediately.
7373+ Ending the stream will propagate an End signal upwards to the root source. */
7474+let subscribe: ('a => unit, (signalT('a) => unit) => unit, unit) => unit;
+11
src/callbagJs.rei
···11open Callbag_types;
2233+/* -- source factories */
44+55+/* Accepts a period in milliseconds and creates a listenable source
66+ that emits ascending numbers for each time the interval fires.
77+ This stream will emit values indefinitely until it receives an
88+ End signal from a talkback passed downwards to its sink. */
39let interval: (int, signalT(int) => unit) => unit;
1010+1111+/* Accepts a JS promise and creates a listenable source that emits
1212+ the promise's value once it resolves.
1313+ This stream will wait for the promise's completion, unless it
1414+ receives an End signal first. */
415let fromPromise: (Js.Promise.t('a), signalT('a) => unit) => unit;