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.

Add initial comments as documentation to the signature files

+76 -5
+65 -5
src/callbag.rei
··· 1 1 open Callbag_types; 2 2 3 + /* -- source factories */ 4 + 5 + /* Accepts a list and creates a pullable source for that list. 6 + The source will emit events when being pulled until the list 7 + is exhausted and it completes */ 3 8 let fromList: (list('a), signalT('a) => unit) => unit; 9 + 10 + /* Accepts an array and creates a pullable source for that array. 11 + The source will emit events when being pulled until the array 12 + is exhausted and it completes */ 4 13 let fromArray: (array('a), signalT('a) => unit) => unit; 5 14 6 - let map: ('a => 'b, (signalT('a) => unit) => unit, signalT('b) => unit) => unit; 7 - let filter: ('a => bool, (signalT('a) => unit) => unit, signalT('a) => unit) => unit; 8 - let scan: (('b, 'a) => 'b, 'b, (signalT('a) => unit) => unit, signalT('b) => unit) => unit; 15 + /* -- operators */ 16 + 17 + /* Takes a mapping function from one type to another, and a source, 18 + and creates a sink & source. 19 + All values that it receives will be transformed using the mapping 20 + function and emitted on the new source */ 21 + let map: 22 + ('a => 'b, (signalT('a) => unit) => unit, signalT('b) => unit) => unit; 23 + 24 + /* Takes a predicate function returning a boolean, and a source, 25 + and creates a sink & source. 26 + All values that it receives will be filtered using the predicate, 27 + and only truthy values will be passed on to the new source. 28 + The sink will attempt to pull a new value when one was filtered. */ 29 + let filter: 30 + ('a => bool, (signalT('a) => unit) => unit, signalT('a) => unit) => unit; 31 + 32 + /* Takes a reducer function, a seed value, and a source, and creates 33 + a sink & source. 34 + The last returned value from the reducer function (or the seed value 35 + initially) will be passed to the reducer together with the value 36 + that the sink receives. All return values of the reducer function 37 + are emitted on the new source. */ 38 + let scan: 39 + (('b, 'a) => 'b, 'b, (signalT('a) => unit) => unit, signalT('b) => unit) => 40 + unit; 41 + 42 + /* Takes an array of sources and creates a sink & source. 43 + All values that the sink receives from all sources will be passed through 44 + to the new source */ 9 45 let merge: (array((signalT('a) => unit) => unit), signalT('a) => unit) => unit; 46 + 47 + /* Takes a listenable or a pullable source and creates a new source that 48 + will ensure that the source is shared between all sinks that follow. 49 + Essentially the original source will only be created once. */ 10 50 let share: ((signalT('a) => unit) => unit, signalT('a) => unit) => unit; 11 - let combine: ((signalT('a) => unit) => unit, (signalT('b) => unit) => unit, signalT(('a, 'b)) => unit) => unit; 51 + 52 + /* Takes two sources and creates a new source & sink. 53 + All latest values from both sources will be passed through as a 54 + tuple of the last values that have been observed */ 55 + let combine: 56 + ( 57 + (signalT('a) => unit) => unit, 58 + (signalT('b) => unit) => unit, 59 + signalT(('a, 'b)) => unit 60 + ) => 61 + unit; 62 + 63 + /* -- sink factories */ 12 64 65 + /* Takes a function and a source, and creates a sink. 66 + The function will be called for each value that the sink receives. 67 + The sink will attempt to pull new values as values come in, until 68 + the source ends. */ 13 69 let forEach: ('a => unit, (signalT('a) => unit) => unit) => unit; 14 - let subscribe: ('a => unit, (signalT('a) => unit) => unit) => (unit => unit); 70 + 71 + /* Similar to the `forEach` sink factory, but returns an anonymous function 72 + that when called will end the stream immediately. 73 + Ending the stream will propagate an End signal upwards to the root source. */ 74 + let subscribe: ('a => unit, (signalT('a) => unit) => unit, unit) => unit;
+11
src/callbagJs.rei
··· 1 1 open Callbag_types; 2 2 3 + /* -- source factories */ 4 + 5 + /* Accepts a period in milliseconds and creates a listenable source 6 + that emits ascending numbers for each time the interval fires. 7 + This stream will emit values indefinitely until it receives an 8 + End signal from a talkback passed downwards to its sink. */ 3 9 let interval: (int, signalT(int) => unit) => unit; 10 + 11 + /* Accepts a JS promise and creates a listenable source that emits 12 + the promise's value once it resolves. 13 + This stream will wait for the promise's completion, unless it 14 + receives an End signal first. */ 4 15 let fromPromise: (Js.Promise.t('a), signalT('a) => unit) => unit;