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.

Expand on types explanation in Callbag_types

- Explain sinks
- Explain talkbacks
- Explain sources

Woohoo

+25
+25
src/callbag_types.re
··· 1 1 /* 2 2 A sink has the signature: `signalT('a) => unit` 3 3 A source thus has the signature: `sink => unit`, or `(signalT('a) => unit) => unit` 4 + 5 + Effectively a sink is a callback receiving signals as its first argument. 6 + - Start(talkback) will be carrying a talkback using which the sink can attempt 7 + to pull values (Pull) or request the source to end its stream (End) 8 + - Push(payload) carries a value that the source sends to the sink. 9 + This can happen at any time, since a source can be both pullable or 10 + merely listenable. 11 + - End signifies the end of the source stream, be it because of a talkback (End) 12 + or because the source is exhausted. 13 + 14 + In detail, a talkback is simply a callback that receives a talkback signal as 15 + its first argument. It's thus typically anonymously created by the source. 16 + 17 + A source is a factory that accepts a sink. Calling a source with a sink will 18 + instantiate and initiate the source's stream, after which the source sends the sink 19 + a talkback (Start(talkback)). This is called the "handshake". 20 + 21 + Typically an operator factory won't call the source with a sink it receives 22 + immediately—because this would cause the operator to simply be a noop—but instead 23 + it will create an intermediate sink with the same signature to perform its own 24 + logic. 25 + 26 + At that point the operator can for instance intercept the talkback for its own 27 + purposes, or call the actual sink as it sees fit. 4 28 */ 29 + 5 30 type talkbackT = 6 31 | Pull 7 32 | End;