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.

Finalise the documentation (#34)

* Update README

* Add docs for fromObservable

* Add docs for fromCallbag

* Add docs for toCallbag and toObservable

* Add docs for buffer

* Add docs for concatAll

* Add docs for mergeAll and mergeMap

* Add docs for share

* Add docs for switchMap and switchAll

* Fix filename of interval source

* Add docs for interval

* Reformat code snippets in operators doc

* Add docs for debounce and throttle

* Move sample operator out of web

The sample operator doesn't use Web-specific APIs
and can hence be moved to be a generic operator.

* Add docs for sample

* Add notes on interoperability to Getting Started

authored by

Phil Plückthun and committed by
GitHub
aa0c97de 244a4269

+716 -267
+20 -53
README.md
··· 26 26 27 27 ![Wonka](/docs/wonka.jpg?raw=true) 28 28 29 - * [What is `Wonka`](#what-is-wonka) 30 - * [Why it exists](#why-it-exists) 31 - * [Installation](#installation) 32 - * [Getting Started](#getting-started) 33 - * [Documentation (In Progress)](#documentation) 29 + Wonka is a lightweight iterable and observable library loosely based on 30 + the [callbag spec](https://github.com/callbag/callbag). It exposes a set of helpers to create streams, 31 + which are sources of multiple values, which allow you to create, transform 32 + and consume event streams or iterable sets of data. 34 33 35 - ## What is `Wonka` 34 + Wonka is written in [Reason](https://reasonml.github.io/), a dialect of OCaml, and can hence be used 35 + for native applications. It is also compiled using [BuckleScript](https://bucklescript.github.io) to plain 36 + JavaScript and has typings for [TypeScript](https://www.typescriptlang.org/) and [Flow](https://flow.org/). 36 37 37 - `Wonka` is a library for lightweight observables and iterables loosely based on the [callbag spec](https://github.com/callbag/callbag). 38 - It exposes a set of helpers to create and transform sources and output sinks, meaning it helps you to turn an event source or an 39 - iterable set of data into streams, and manipulate these streams. 38 + This means that out of the box Wonka is usable in any project that use the following: 40 39 41 - Reason has been becoming increasingly popular, but it's missing a good pattern for streams that feels native to the language. 42 - The functional nature of callbags make them a perfect starting point to fix this, and to introduce a reactive programming 43 - pattern to a language that is well suited for it. 44 - 45 - This library also attempts to support as many Reason/JS environments as possible, which makes the adoption of streams across 46 - multiple projects a lot easier. Hence `Wonka` is a library that aims to make complex streams of data easy to deal with. 47 - 48 - ## Compatibility 49 - 50 - `Wonka` is not only compatible with Reason/Bucklescript, but out of the box with other environments as well. 51 - 40 + - Plain JavaScript 52 41 - TypeScript 53 - - JS/Flow 54 - - Reason/OCaml Bucklescript 55 - - Reason/OCaml `bs-native` 56 - - Reason/OCaml Dune 42 + - Flow 43 + - Reason/OCaml with BuckleScript 44 + - Reason/OCaml with `bs-native` 45 + - Reason/OCaml with Dune and Esy 57 46 58 - In summary, it should work in any TypeScript/Flow/Reason/OCaml environment with full type safety. 59 - 60 - ## Installation 61 - 62 - Install the library first: `yarn add wonka` or `npm install --save wonka`, 63 - 64 - ### BuckleScript 65 - 66 - For Bucklescript you will also need to add `wonka` to `bs-dependencies` in your `bsconfig.json` file like so: 67 - 68 - ```diff 69 - { 70 - "name": "<your name>", 71 - "version": "0.1.0", 72 - "sources": ["src"], 73 - "bsc-flags": ["-bs-super-errors"], 74 - "bs-dependencies": [ 75 - + "wonka" 76 - ] 77 - } 78 - ``` 47 + ## [Documentation](https://wonka.kitten.sh/) 79 48 80 - ## Documentation 49 + **See the documentation at [wonka.kitten.sh](https://wonka.kitten.sh)** for more information about using `wonka`! 81 50 82 - This is still a work-in-progress but will contain full information on the following 83 - across all supported languages: 51 + - [Introduction](https://wonka.kitten.sh/) 52 + - [**Getting started**](https://wonka.kitten.sh/getting-started) 53 + - [Basics](https://wonka.kitten.sh/basics/) 54 + - [API Reference](https://wonka.kitten.sh/api/) 84 55 85 - - The API, i.e. a list of all helpers 86 - - Examples 87 - - Usage Guides & Recipes 88 - - Developer Guides (How to write a source/operator/sink) 89 - - Modified Callbag spec 56 + The raw markdown files can be found [in this repository in the `docs` folder](https://github.com/kitten/wonka/tree/master/docs).
+59 -59
__tests__/wonka_test.re
··· 322 322 }); 323 323 }); 324 324 325 + describe("sample", () => { 326 + open Expect; 327 + open! Expect.Operators; 328 + 329 + afterEach(() => Jest.useRealTimers()); 330 + 331 + it("should sample the last emitted value from a source", () => { 332 + Jest.useFakeTimers(); 333 + let a = Wonka.interval(50); 334 + 335 + let talkback = ref((. _: Wonka_types.talkbackT) => ()); 336 + let signals = [||]; 337 + 338 + let source = Wonka.sample(Wonka.interval(100), a); 339 + 340 + source((. signal) => 341 + switch (signal) { 342 + | Start(x) => 343 + talkback := x; 344 + x(. Pull); 345 + | Push(_) => 346 + ignore(Js.Array.push(signal, signals)); 347 + talkback^(. Pull); 348 + | End => ignore(Js.Array.push(signal, signals)) 349 + } 350 + ); 351 + 352 + Jest.runTimersToTime(200); 353 + 354 + expect(signals) == [|Push(1), Push(3)|]; 355 + }); 356 + 357 + it("should emit an End signal when the source has emitted all values", () => { 358 + Jest.useFakeTimers(); 359 + let a = Wonka.interval(50); 360 + 361 + let talkback = ref((. _: Wonka_types.talkbackT) => ()); 362 + let signals = [||]; 363 + 364 + let source = Wonka.sample(Wonka.interval(100), a) |> Wonka.take(3); 365 + 366 + source((. signal) => 367 + switch (signal) { 368 + | Start(x) => 369 + talkback := x; 370 + x(. Pull); 371 + | Push(_) => 372 + ignore(Js.Array.push(signal, signals)); 373 + talkback^(. Pull); 374 + | End => ignore(Js.Array.push(signal, signals)) 375 + } 376 + ); 377 + 378 + Jest.runTimersToTime(300); 379 + 380 + expect(signals) == [|Push(1), Push(3), Push(5), End|]; 381 + }); 382 + }); 383 + 325 384 describe("scan", () => { 326 385 open Expect; 327 386 ··· 2025 2084 Jest.runTimersToTime(3000); 2026 2085 2027 2086 expect(signals) == [|Push(1), Push(2), Push(3), End|]; 2028 - }); 2029 - }); 2030 - 2031 - describe("sample", () => { 2032 - open Expect; 2033 - open! Expect.Operators; 2034 - 2035 - afterEach(() => Jest.useRealTimers()); 2036 - 2037 - it("should sample the last emitted value from a source", () => { 2038 - Jest.useFakeTimers(); 2039 - let a = Wonka.interval(50); 2040 - 2041 - let talkback = ref((. _: Wonka_types.talkbackT) => ()); 2042 - let signals = [||]; 2043 - 2044 - let source = WonkaJs.sample(Wonka.interval(100), a); 2045 - 2046 - source((. signal) => 2047 - switch (signal) { 2048 - | Start(x) => 2049 - talkback := x; 2050 - x(. Pull); 2051 - | Push(_) => 2052 - ignore(Js.Array.push(signal, signals)); 2053 - talkback^(. Pull); 2054 - | End => ignore(Js.Array.push(signal, signals)) 2055 - } 2056 - ); 2057 - 2058 - Jest.runTimersToTime(200); 2059 - 2060 - expect(signals) == [|Push(1), Push(3)|]; 2061 - }); 2062 - 2063 - it("should emit an End signal when the source has emitted all values", () => { 2064 - Jest.useFakeTimers(); 2065 - let a = Wonka.interval(50); 2066 - 2067 - let talkback = ref((. _: Wonka_types.talkbackT) => ()); 2068 - let signals = [||]; 2069 - 2070 - let source = WonkaJs.sample(Wonka.interval(100), a) |> Wonka.take(3); 2071 - 2072 - source((. signal) => 2073 - switch (signal) { 2074 - | Start(x) => 2075 - talkback := x; 2076 - x(. Pull); 2077 - | Push(_) => 2078 - ignore(Js.Array.push(signal, signals)); 2079 - talkback^(. Pull); 2080 - | End => ignore(Js.Array.push(signal, signals)) 2081 - } 2082 - ); 2083 - 2084 - Jest.runTimersToTime(300); 2085 - 2086 - expect(signals) == [|Push(1), Push(3), Push(5), End|]; 2087 2087 }); 2088 2088 }); 2089 2089
+430 -151
docs/api/operators.md
··· 5 5 6 6 Operators in Wonka allow you to transform values from a source before they are sent to a sink. Wonka has the following operators. 7 7 8 + ## buffer 9 + 10 + Buffers emissions from an outer source and emits a buffer array of items every time an 11 + inner source (notifier) emits. 12 + 13 + This operator can be used to group values into a arrays on a source. The emitted values will 14 + be sent when a notifier fires and will be arrays of all items before the notification event. 15 + 16 + In combination with `interval` this can be used to group values in chunks regularly. 17 + 18 + ```reason 19 + Wonka.interval(50) 20 + |> Wonka.buffer(Wonka.interval(100)) 21 + |> Wonka.take(2) 22 + |> Wonka.subscribe((. buffer) => { 23 + Js.Array.forEach(num => print_int(num), buffer); 24 + print_endline(";"); 25 + }); 26 + /* Prints 1 2; 2 3 to the console. */ 27 + ``` 28 + 29 + ``` typescript 30 + import { pipe, interval, buffer, take, subscribe } from 'wonka'; 31 + 32 + pipe( 33 + interval(50), 34 + buffer(interval(100)), 35 + take(2), 36 + subscribe(buffer => { 37 + buffer.forEach(x => console.log(x)); 38 + console.log(';'); 39 + }) 40 + ); // Prints 1 2; 2 3 to the console. 41 + ``` 42 + 8 43 ## combine 9 44 10 45 `combine` two sources together to a single source. The emitted value will be a combination of the two sources, with all values from the first source being emitted with the first value of the second source _before_ values of the second source are emitted. ··· 14 49 let sourceTwo = Wonka.fromArray([|4, 5, 6|]); 15 50 16 51 Wonka.combine(sourceOne, sourceTwo) 17 - |> Wonka.subscribe((. (_valOne, _valTwo)) => print_int(_valOne + _valTwo)); 52 + |> Wonka.subscribe((. (a, b)) => print_int(a + b)); 18 53 19 54 /* Prints 56789 (1+4, 2+4, 3+4, 3+5, 3+6) to the console. */ 20 55 ``` ··· 30 65 subscribe(([valOne, valTwo]) => { 31 66 console.log(valOne + valTwo); 32 67 }) 33 - ); 34 - 35 - // Prints 56789 (1+4, 2+4, 3+4, 3+5, 3+6) to the console. 68 + ); // Prints 56789 (1+4, 2+4, 3+4, 3+5, 3+6) to the console. 36 69 ``` 37 70 38 71 ## concat ··· 40 73 `concat` will combine two sources together, subscribing to the next source after the previous source completes. 41 74 42 75 ```reason 43 - let sourceOne = Wonka.fromArray([|1, 2, 3, 4, 5, 6|]); 44 - let sourceTwo = Wonka.fromArray([|6, 5, 4, 3, 2, 1|]); 45 - 46 - Wonka.concat([|sourceOne, sourceTwo|]) |> Wonka.subscribe((. _val) => print_int(_val)); 76 + let sourceOne = Wonka.fromArray([|1, 2, 3|]); 77 + let sourceTwo = Wonka.fromArray([|6, 5, 4|]); 47 78 48 - /* Prints 1 2 3 4 5 6 6 5 4 3 2 1 to the console. */ 79 + Wonka.concat([|sourceOne, sourceTwo|]) 80 + |> Wonka.subscribe((. x) => print_int(x)); 81 + /* Prints 1 2 3 6 5 4 to the console. */ 49 82 ``` 50 83 51 84 ```typescript 52 85 import { fromArray, pipe, concat, subscribe } from 'wonka'; 53 86 54 - const sourceOne = fromArray([1, 2, 3, 4, 5, 6]); 55 - const sourceTwo = fromArray([6, 5, 4, 3, 2, 1]); 87 + const sourceOne = fromArray([1, 2, 3]); 88 + const sourceTwo = fromArray([6, 5, 4]); 56 89 57 90 pipe( 58 91 concat([sourceOne, sourceTwo]), 59 - subscribe(val => { 60 - console.log(val); 61 - }) 62 - ); 92 + subscribe(val => console.log(val)) 93 + ); // Prints 1 2 3 6 5 4 to the console. 94 + ``` 63 95 64 - // Prints 1 2 3 4 5 6 6 5 4 3 2 1 to the console. 96 + ## concatAll 97 + 98 + `concatAll` will combine all sources emitted on an outer source together, subscribing to the 99 + next source after the previous source completes. 100 + 101 + It's very similar to `concat`, but instead accepts a source of sources as an input. 102 + 103 + ```reason 104 + let sourceOne = Wonka.fromArray([|1, 2, 3|]); 105 + let sourceTwo = Wonka.fromArray([|6, 5, 4|]); 106 + 107 + Wonka.fromList([sourceOne, sourceTwo]) 108 + |> Wonka.concatAll 109 + |> Wonka.subscribe((. x) => print_int(x)); 110 + /* Prints 1 2 3 6 5 4 to the console. */ 111 + ``` 112 + 113 + ```typescript 114 + import { pipe, fromArray, concatAll, subscribe } from 'wonka'; 115 + 116 + const sourceOne = fromArray([1, 2, 3]); 117 + const sourceTwo = fromArray([6, 5, 4]); 118 + 119 + pipe( 120 + fromArray([sourceOne, sourceTwo]), 121 + concatAll, 122 + subscribe(val => console.log(val)) 123 + ); // Prints 1 2 3 6 5 4 to the console. 65 124 ``` 66 125 67 126 ## concatMap ··· 95 154 delay(val * 1000) 96 155 ); 97 156 }), 98 - subscribe(val => { 99 - console.log(val); 100 - }) 157 + subscribe(val => console.log(val)) 158 + ); 159 + ``` 160 + 161 + 162 + ## delay 163 + 164 + `delay` delays all emitted values of a source by the given amount of milliseconds. 165 + 166 + > _Note:_ This operator is only available in JavaScript environments, and will be excluded 167 + > when compiling natively. 168 + 169 + ```reason 170 + Wonka.fromList([1, 2]) 171 + |> Wonka.delay(10) 172 + |> Wonka.subscribe((. x) => print_int(x)); 173 + /* waits 10ms then prints 1, waits 10ms then prints 2, waits 10ms then ends */ 174 + ``` 175 + 176 + ```typescript 177 + import { pipe, fromArray, delay, subscribe } from 'wonka'; 178 + 179 + pipe( 180 + fromArray([1, 2]), 181 + delay(10) 182 + subscribe(val => console.log(val)) 183 + ); 184 + // waits 10ms then prints 1, waits 10ms then prints 2, waits 10ms then ends 185 + ``` 186 + 187 + ## debounce 188 + 189 + `debounce` doesn't emit values of a source until no values have been emitted after 190 + a given amount of milliseconds. Once this threshold of silence has been reached, the 191 + last value that has been received will be emitted. 192 + 193 + > _Note:_ This operator is only available in JavaScript environments, and will be excluded 194 + > when compiling natively. 195 + 196 + ```reason 197 + let sourceA = Wonka.interval(10) 198 + |> Wonka.take(5); 199 + let sourceB = Wonka.fromValue(1); 200 + 201 + Wonka.concat([|sourceA, sourceB|]) 202 + |> Wonka.debounce((. _x) => 20) 203 + |> Wonka.subscribe((. x) => print_int(x)); 204 + /* The five values from sourceA will be omitted */ 205 + /* After these values and after 20ms `1` will be logged */ 206 + ``` 207 + 208 + ```typescript 209 + import { pipe, interval, take, fromValue, concat, debounce, subscribe } from 'wonka'; 210 + 211 + const sourceA = pipe(interval(10), take(5)); 212 + const sourceB = fromValue(1); 213 + 214 + pipe( 215 + concat([sourceA, sourceB]) 216 + debounce(() => 20), 217 + subscribe(val => console.log(val)) 101 218 ); 219 + 220 + // The five values from sourceA will be omitted 221 + // After these values and after 20ms `1` will be logged 102 222 ``` 103 223 104 224 ## filter ··· 106 226 `filter` will remove values from a source by passing them through an iteratee that returns a `bool`. 107 227 108 228 ```reason 109 - let source = Wonka.fromArray([|1, 2, 3, 4, 5, 6|]); 110 229 let isEven = (. n) => n mod 2 === 0; 111 230 112 - source |> Wonka.filter(isEven) |> Wonka.subscribe((. _val) => print_int(_val)); 113 - 231 + Wonka.fromArray([|1, 2, 3, 4, 5, 6|]) 232 + |> Wonka.filter(isEven) 233 + |> Wonka.subscribe((. x) => print_int(x)); 114 234 /* Prints 246 to the console. */ 115 235 ``` 116 236 117 237 ```typescript 118 238 import { fromArray, filter, subscribe } from 'wonka'; 119 239 120 - const source = fromArray([1, 2, 3, 4, 5, 6]); 121 240 const isEven = n => n % 2 === 0; 122 241 123 242 pipe( 124 - source, 243 + fromArray([1, 2, 3, 4, 5, 6]), 125 244 filter(isEven), 126 - subscribe(val => { 127 - console.log(val); 128 - }) 245 + subscribe(val => console.log(val)) 129 246 ); 130 247 131 248 // Prints 246 to the console. ··· 136 253 `map` will transform values from a source by passing them through an iteratee that returns a new value. 137 254 138 255 ```reason 139 - let source = Wonka.fromArray([|1, 2, 3, 4, 5, 6|]); 140 256 let square = (. n) => n * n; 141 257 142 - source |> Wonka.map(square) |> Wonka.subscribe((. _val) => print_int(_val)); 143 - 258 + Wonka.fromArray([|1, 2, 3, 4, 5, 6|]) 259 + |> Wonka.map(square) 260 + |> Wonka.subscribe((. x) => print_int(x)); 144 261 /* Prints 1 4 9 16 25 36 to the console. */ 145 262 ``` 146 263 147 264 ```typescript 148 265 import { fromArray, pipe, map, subscribe } from 'wonka'; 149 266 150 - const source = fromArray([1, 2, 3, 4, 5, 6]); 151 267 const square = n => n * n; 152 268 153 269 pipe( 154 - source, 270 + fromArray([1, 2, 3, 4, 5, 6]), 155 271 map(square), 156 - subscribe(val => { 157 - console.log(val); 158 - }) 272 + subscribe(val => console.log(val)) 159 273 ); 160 274 161 275 // Prints 1 4 9 16 25 36 to the console. ··· 163 277 164 278 ## merge 165 279 166 - `merge` two sources together into a single source. 280 + `merge` merges an array of sources together into a single source. It subscribes 281 + to all sources that it's passed and emits all their values on the output source. 167 282 168 283 ```reason 169 284 let sourceA = Wonka.fromArray([|1, 2, 3|]); 170 285 let sourceB = Wonka.fromArray([|4, 5, 6|]); 171 286 172 - Wonka.merge([|sourceA, sourceB|]) |> Wonka.subscribe((. _val) => print_int(_val)); 287 + Wonka.merge([|sourceA, sourceB|]) 288 + |> Wonka.subscribe((. x) => print_int(x)); 289 + /* Prints 1 2 3 4 5 6 to the console. */ 290 + ``` 173 291 174 - /* Prints 1 2 3 4 5 6 to the console. 292 + ```typescript 293 + import { fromArray, pipe, merge, subscribe } from 'wonka'; 294 + 295 + const sourceOne = fromArray([1, 2, 3]); 296 + const sourceTwo = fromArray([4, 5, 6]); 297 + 298 + pipe( 299 + merge(sourceOne, sourceTwo), 300 + subscribe((val) => console.log(val)) 301 + ); // Prints 1 2 3 4 5 6 to the console. 302 + ``` 303 + 304 + ## mergeAll 305 + 306 + `mergeAll` will merge all sources emitted on an outer source into a single one. 307 + It's very similar to `merge`, but instead accepts a source of sources as an input. 308 + 309 + > _Note:_ This operator is also exported as `flatten` which is just an alias for `mergeAll` 310 + 311 + ```reason 312 + let sourceA = Wonka.fromArray([|1, 2, 3|]); 313 + let sourceB = Wonka.fromArray([|4, 5, 6|]); 314 + 315 + Wonka.fromList([sourceA, sourceB]) 316 + |> Wonka.mergeAll 317 + |> Wonka.subscribe((. x) => print_int(x)); 318 + /* Prints 1 2 3 4 5 6 to the console. */ 175 319 ``` 176 320 177 321 ```typescript 178 - import { fromArray, pipe, merge, subscribe } from 'wonka'; 322 + import { pipe, fromArray, mergeAll, subscribe } from 'wonka'; 179 323 180 324 const sourceOne = fromArray([1, 2, 3]); 181 325 const sourceTwo = fromArray([4, 5, 6]); 182 326 183 327 pipe( 184 - merge(sourceOne, sourceTwo) 185 - subscribe((val) => { 186 - console.log(val); 187 - }) 188 - ); 328 + fromArray([sourceOne, sourceTwo]), 329 + mergeAll, 330 + subscribe(val => console.log(val)) 331 + ); // Prints 1 2 3 4 5 6 to the console. 332 + ``` 189 333 190 - // Prints 1 2 3 4 5 6 to the console. 334 + ## mergeMap 335 + 336 + `mergeMap` allows you to map values of an outer source to an inner source. 337 + This allows you to create nested sources for each emitted value, which will 338 + all be merged into a single source, like with `mergeAll`. 339 + 340 + Unlike `concatMap` all inner sources will be subscribed to at the same time 341 + and all their values will be emitted on the output source as they come in. 342 + 343 + ```reason 344 + Wonka.fromList([1, 2]) 345 + |> Wonka.mergeMap((. value) => 346 + Wonka.fromList([value - 1, value])) 347 + |> Wonka.subscribe((. x) => print_int(x)); 348 + /* Prints 0 1 1 2 to the console. */ 349 + ``` 350 + 351 + ```typescript 352 + import { pipe, fromArray, mergeMap, subscribe } from 'wonka'; 353 + 354 + pipe( 355 + fromArray([1, 2]), 356 + mergeMap(x => fromArray([x - 1, x])), 357 + subscribe(val => console.log(val)) 358 + ); // Prints 0 1 1 2 to the console. 191 359 ``` 192 360 193 361 ## onEnd ··· 207 375 208 376 let sourceOne = Wonka.fromPromise(promiseOne); 209 377 let sourceTwo = Wonka.fromPromise(promiseTwo); 210 - let source = Wonka.concat([|sourceOne, sourceTwo|]); 211 378 212 - source 213 - |> Wonka.onEnd((.) => print_endline("onEnd")) 214 - |> Wonka.subscribe((. _val) => print_endline(_val)); 379 + Wonka.concat([|sourceOne, sourceTwo|]) 380 + |> Wonka.onEnd((.) => print_endline("onEnd")) 381 + |> Wonka.subscribe((. x) => print_endline(x)); 215 382 216 383 /* Logs ResolveOne after one second, then ResolveTwo after an additional second, then onEnd immediately. */ 217 384 ``` ··· 232 399 233 400 const sourceOne = fromPromise(promiseOne); 234 401 const sourceTwo = fromPromise(promiseTwo); 235 - const source = concat([sourceOne, sourceTwo]); 236 402 237 403 pipe( 238 - source, 239 - onEnd(() => { 240 - console.log('onEnd'); 241 - }), 242 - subscribe(val => { 243 - console.log(val); 244 - }) 404 + concat([sourceOne, sourceTwo]), 405 + onEnd(() => console.log('onEnd')), 406 + subscribe(val => console.log(val)) 245 407 ); 246 408 247 409 // Logs ResolveOne after one second, then ResolveTwo after an additional second, then onEnd immediately. ··· 252 414 Run a callback on each `Push` signal sent to the sink by the source. 253 415 254 416 ```reason 255 - let source = Wonka.fromArray([|1, 2, 3, 4, 5, 6|]); 256 - 257 - Wonka.source 258 - |> Wonka.onPush((. _val) => print_string({j|Push $_val|j})) 259 - |> Wonka.subscribe((. _val) => print_int(_val)); 260 - 417 + Wonka.fromArray([|1, 2, 3, 4, 5, 6|]) 418 + |> Wonka.onPush((. x) => print_string({j|Push $x|j})) 419 + |> Wonka.subscribe((. x) => print_int(x)); 261 420 /* Prints Push 1 1 Push 2 2 Push 3 3 Push 4 4 Push 5 5 Push 6 6 to the console. */ 262 421 ``` 263 422 264 423 ```typescript 265 424 import { fromArray, pipe, onPush, subscribe } from 'wonka'; 266 - 267 - const source = fromArray([1, 2, 3, 4, 5, 6]); 268 425 269 426 pipe( 270 - source, 271 - onPush(val => { 272 - console.log(`Push ${val}`); 273 - }), 274 - subscribe(val => { 275 - console.log(val); 276 - }) 277 - ); 278 - 279 - // Prints Push 1 1 Push 2 2 Push 3 3 Push 4 4 Push 5 5 Push 6 6 to the console. 427 + fromArray([1, 2, 3, 4, 5, 6]), 428 + onPush(val => console.log(`Push ${val}`)), 429 + subscribe(val => console.log(val)) 430 + ); // Prints Push 1 1 Push 2 2 Push 3 3 Push 4 4 Push 5 5 Push 6 6 to the console. 280 431 ``` 281 432 282 433 ## onStart ··· 289 440 Js.Global.setTimeout(() => resolve(. "Resolve"), 1000) |> ignore 290 441 ); 291 442 292 - let source = Wonka.fromPromise(promise); 293 - 294 - source 295 - |> Wonka.onStart((.) => print_endline("onStart")) 296 - |> Wonka.subscribe((. _val) => print_endline(_val)); 297 - 443 + Wonka.fromPromise(promise) 444 + |> Wonka.onStart((.) => print_endline("onStart")) 445 + |> Wonka.subscribe((. _val) => print_endline(_val)); 298 446 /* Logs onStart to the console, pauses for one second to allow the timeout to finish, 299 447 then logs "Resolve" to the console. */ 300 448 ``` ··· 308 456 }, 1000); 309 457 }); 310 458 311 - const source = fromPromise(promise); 312 - 313 459 pipe( 314 - source, 315 - onStart(() => { 316 - console.log('onStart'); 317 - }), 318 - subscribe(val => { 319 - console.log(val); 320 - }) 460 + fromPromise(promise), 461 + onStart(() => console.log('onStart')), 462 + subscribe(val => console.log(val)) 321 463 ); 322 464 323 465 // Logs onStart to the console, pauses for one second to allow the timeout to finish, 324 466 // then logs "Resolve" to the console. 325 467 ``` 326 468 469 + ## sample 470 + 471 + `sample` emits the previously emitted value from an outer source every time 472 + an inner source (notifier) emits. 473 + 474 + In combination with `interval` it can be used to get values from a noisy source 475 + more regularly. 476 + 477 + ```reason 478 + Wonka.interval(10) 479 + |> Wonka.sample(Wonka.interval(100)) 480 + |> Wonka.take(2) 481 + |> Wonka.subscribe((. x) => print_int(x)); 482 + /* Prints 10 20 to the console. */ 483 + ``` 484 + 485 + ``` typescript 486 + import { pipe, interval, sample, take, subscribe } from 'wonka'; 487 + 488 + pipe( 489 + interval(10), 490 + sample(interval(100)), 491 + take(2), 492 + subscribe(x => console.log(x)) 493 + ); // Prints 10 20 to the console. 494 + ``` 495 + 327 496 ## scan 328 497 329 498 Accumulate emitted values of a source in a accumulator, similar to JavaScript `reduce`. 330 499 331 500 ```reason 332 - let source = Wonka.fromArray([|1, 2, 3, 4, 5, 6|]); 333 - 334 - source 335 - |> Wonka.scan((. acc, x) => acc + x, 0) 336 - |> Wonka.subscribe((. _val) => print_int(_val)); 501 + Wonka.fromArray([|1, 2, 3, 4, 5, 6|]) 502 + |> Wonka.scan((. acc, x) => acc + x, 0) 503 + |> Wonka.subscribe((. x) => print_int(x)); 337 504 /* Prints 1 3 6 10 15 21 to the console. */ 338 505 ``` 339 506 340 507 ```typescript 341 508 import { fromArray, pipe, scan, subscribe } from 'wonka'; 342 509 343 - const source = fromArray([1, 2, 3, 4, 5, 6]); 344 - 345 510 pipe( 346 - source, 511 + fromArray([1, 2, 3, 4, 5, 6]), 347 512 scan((acc, val) => acc + val), 348 - subscribe(val => { 349 - console.log(val); 350 - }) 513 + subscribe(val => console.log(val)) 351 514 ); 352 515 353 516 // Prints 1 3 6 10 15 21 to the console. 354 517 ``` 355 518 356 - ## skip 519 + ## share 520 + 521 + `share` ensures that all subscriptions to the underlying source are shared. 357 522 358 - `skip` the specified number of emissions from the source. 523 + By default Wonka's sources are lazy. They only instantiate themselves and begin 524 + emitting signals when they're being subscribed to, since they're also immutable. 525 + This means that when a source is used in multiple places, their underlying subscription 526 + is not shared. Instead, the entire chain of sources and operators will be instantiated 527 + separately every time. 528 + 529 + The `share` operator prevents this by creating an output source that will reuse a single 530 + subscription to the parent source, which will be unsubscribed from when no sinks are 531 + listening to it anymore. 532 + 533 + This is especially useful if you introduce side-effects to your sources, 534 + for instance with `onStart`. 359 535 360 536 ```reason 361 - let source = Wonka.fromArray([|1, 2, 3, 4, 5, 6|]); 537 + let source = Wonka.never 538 + |> Wonka.onStart((.) => print_endline("start")) 539 + |> Wonka.share; 362 540 363 - source |> Wonka.skip(2) |> Wonka.subscribe((. _val) => print_int(_val)); 541 + /* Without share this would print "start" twice: */ 542 + Wonka.publish(source); 543 + Wonka.publish(source); 544 + ``` 545 + 546 + ```typescript 547 + import { pipe, never, onStart, share, publish } from 'wonka'; 548 + 549 + const source = pipe( 550 + never 551 + onStart(() => console.log('start')), 552 + share 553 + ); 364 554 555 + // Without share this would print "start" twice: 556 + publish(source); 557 + publish(source); 558 + ``` 559 + 560 + ## skip 561 + 562 + `skip` the specified number of emissions from the source. 563 + 564 + ```reason 565 + Wonka.fromArray([|1, 2, 3, 4, 5, 6|]) 566 + |> Wonka.skip(2) 567 + |> Wonka.subscribe((. x) => print_int(x)); 365 568 /* Prints 3 4 5 6 to the console, since the first two emissions from the source were skipped. 366 569 ``` 367 570 368 571 ```typescript 369 572 import { fromArray, pipe, skip, subscribe } from 'wonka'; 370 573 371 - const source = fromArray([1, 2, 3, 4, 5, 6]); 372 - 373 574 pipe( 374 - source, 575 + fromArray([1, 2, 3, 4, 5, 6]), 375 576 skip(2), 376 - subscribe(val => { 377 - console.log(val); 378 - }) 577 + subscribe(val => console.log(val)) 379 578 ); 380 579 ``` 381 580 ··· 387 586 let source = Wonka.interval(100); 388 587 let notifier = Wonka.interval(500); 389 588 390 - source |> Wonka.skipUntil(notifier) |> Wonka.subscribe((. _val) => print_int(_val)); 589 + source 590 + |> Wonka.skipUntil(notifier) 591 + |> Wonka.subscribe((. x) => print_int(x)); 391 592 392 593 /* Skips all values emitted by source (0, 1, 2, 3) until notifier emits at 500ms. 393 594 Then logs 4 5 6 7 8 9 10... to the console every 500ms. */ ··· 402 603 pipe( 403 604 source, 404 605 skipUntil(notifier), 405 - subscribe(val => { 406 - console.log(val); 407 - }) 606 + subscribe(val => console.log(val)) 408 607 ); 409 608 410 609 // Skips all values emitted by source (0, 1, 2, 3) until notifier emits at 500ms. ··· 428 627 ```typescript 429 628 import { fromArray, pipe, skipWhile, subscribe } from 'wonka'; 430 629 431 - const source = fromArray([1, 2, 3, 4, 5, 6]); 432 - 433 630 pipe( 434 - source, 631 + fromArray([1, 2, 3, 4, 5, 6]), 435 632 skipWhile(val => val < 5), 436 - subscribe(val => { 437 - console.log(val); 438 - }) 633 + subscribe(val => console.log(val)) 439 634 ); 440 635 441 636 // Prints 5 6 to the console, as 1 2 3 4 all return true for the predicate function. 442 637 ``` 443 638 639 + ## switchMap 640 + 641 + `switchMap` allows you to map values of an outer source to an inner source. 642 + The inner source's values will be emitted on the returned output source. If 643 + a new inner source is returned, because the outer source emitted a new value 644 + before the previous inner source completed, the inner source is closed and unsubscribed 645 + from. 646 + 647 + This is similar to `concatMap` but instead of waiting for the last inner source to complete 648 + before emitting values from the next, `switchMap` just cancels the previous inner source. 649 + 650 + ```reason 651 + Wonka.interval(50) 652 + |> Wonka.switchMap((. _value) => 653 + Wonka.interval(40)) 654 + |> Wonka.take(3) 655 + |> Wonka.subscribe((. x) => print_int(x)); 656 + /* Prints 1 2 3 to the console. */ 657 + /* The inner interval is cancelled after its first value every time */ 658 + ``` 659 + 660 + ```typescript 661 + import { pipe, interval, switchMap, take, subscribe } from 'wonka'; 662 + 663 + pipe( 664 + interval(50), 665 + // The inner interval is cancelled after its first value every time 666 + switchMap(value => interval(40)), 667 + take(3), 668 + subscribe(x => console.log(x)) 669 + ); // Prints 1 2 3 to the console 670 + ``` 671 + 672 + ## switchAll 673 + 674 + `switchAll` will combined sources emitted on an outer source together, subscribing 675 + to only one source at a time, and cancelling the previous inner source, when it hasn't 676 + ended while the next inner source is created. 677 + 678 + It's very similar to `switchMap`, but instead accepts a source of sources. 679 + 680 + ```reason 681 + Wonka.interval(50) 682 + |> Wonka.map((. _value) => 683 + Wonka.interval(40)) 684 + |> Wonka.switchAll 685 + |> Wonka.take(3) 686 + |> Wonka.subscribe((. x) => print_int(x)); 687 + /* Prints 1 2 3 to the console. */ 688 + ``` 689 + 690 + ```typescript 691 + import { pipe, interval, map, switchAll, take, subscribe } from 'wonka'; 692 + 693 + pipe( 694 + interval(50), 695 + map(() => interval(40)), 696 + switchAll, 697 + take(3), 698 + subscribe(x => console.log(x)) 699 + ); // Prints 1 2 3 to the console 700 + ``` 701 + 702 + These examples are practically identical to the `switchMap` examples, but note 703 + that `map` was used instead of using `switchMap` directly. This is because combining 704 + `map` with a subsequent `switchAll` is the same as using `switchMap`. 705 + 444 706 ## take 445 707 446 708 `take` only a specified number of emissions from the source before completing. `take` is the opposite of `skip`. 447 709 448 710 ```reason 449 - let source = Wonka.fromArray([|1, 2, 3, 4, 5, 6|]); 450 - 451 - source |> Wonka.take(3) |> Wonka.subscribe((. _val) => print_int(_val)); 452 - 711 + Wonka.fromArray([|1, 2, 3, 4, 5, 6|]) 712 + |> Wonka.take(3) 713 + |> Wonka.subscribe((. x) => print_int(x)); 453 714 /* Prints 1 2 3 to the console. */ 454 715 ``` 455 716 456 717 ```typescript 457 718 import { fromArray, pipe, take, subscribe } from 'wonka'; 458 719 459 - const source = fromArray([1, 2, 3, 4, 5, 6]); 460 - 461 720 pipe( 462 - source, 721 + fromArray([1, 2, 3, 4, 5, 6]), 463 722 take(3), 464 - subscribe(val => { 465 - console.log(val); 466 - }) 723 + subscribe(val => console.log(val)) 467 724 ); 468 725 469 726 // Prints 1 2 3 to the console. ··· 474 731 `takeLast` will take only the last n emissions from the source. 475 732 476 733 ```reason 477 - let source = Wonka.fromArray([|1, 2, 3, 4, 5, 6|]); 478 - 479 - source |> Wonka.takeLast(3) |> Wonka.subscribe((. _val) => print_int(_val)); 480 - 734 + Wonka.fromArray([|1, 2, 3, 4, 5, 6|]); 735 + |> Wonka.takeLast(3) 736 + |> Wonka.subscribe((. x) => print_int(x)); 481 737 /* Prints 4 5 6 to the console. */ 482 738 ``` 483 739 484 740 ```typescript 485 741 import { fromArray, pipe, takeLast, subscribe } from 'wonka'; 486 742 487 - const source = fromArray([1, 2, 3, 4, 5, 6]); 488 - 489 743 pipe( 490 - source, 744 + fromArray([1, 2, 3, 4, 5, 6]), 491 745 takeLast(3), 492 - subscribe(val => { 493 - console.log(val); 494 - }) 746 + subscribe(val => console.log(val)) 495 747 ); 496 748 497 749 // Prints 4 5 6 to the console. ··· 506 758 let notifier = Wonka.interval(500); 507 759 508 760 source 509 - |> Wonka.takeUntil(notifier) 510 - |> Wonka.subscribe((. _val) => print_int(_val)); 761 + |> Wonka.takeUntil(notifier) 762 + |> Wonka.subscribe((. x) => print_int(x)); 511 763 512 764 /* Pauses 100ms, prints 0, pauses 100ms, prints 1, pauses 100ms, prints 2, pauses 100ms, 513 765 prints 3, pauses 100, then completes (notifier emits). */ ··· 522 774 pipe( 523 775 source, 524 776 takeUntil(notifier), 525 - subscribe(val => { 526 - console.log(val); 527 - }) 777 + subscribe(val => console.log(val)) 528 778 ); 529 779 530 780 // Pauses 100ms, prints 0, pauses 100ms, prints 1, pauses 100ms, prints 2, pauses 100ms, ··· 539 789 let source = Wonka.fromArray([|1, 2, 3, 4, 5, 6|]); 540 790 541 791 source 542 - |> Wonka.takeWhile((. _val) => _val < 5) 543 - |> Wonka.subscribe((. _val) => print_int(_val)); 792 + |> Wonka.takeWhile((. x) => x < 5) 793 + |> Wonka.subscribe((. x) => print_int(x)); 544 794 545 795 /* Prints 1 2 3 4 to the console. */ 546 796 ``` ··· 553 803 pipe( 554 804 source, 555 805 takeWhile(val => val < 5), 556 - subscribe(val => { 557 - console.log(val); 558 - }) 806 + subscribe(val => console.log(val)) 559 807 ); 560 808 561 809 // Prints 1 2 3 4 to the console. 562 810 ``` 811 + 812 + ## throttle 813 + 814 + `throttle` emits values of a source, but after each value it will omit all values for 815 + the given amount of milliseconds. It enforces a time of silence after each value it 816 + receives and skips values while the silence is still ongoing. 817 + 818 + This is very similar to `debounce` but instead of waiting for leading time before a 819 + value it waits for trailing time after a value. 820 + 821 + > _Note:_ This operator is only available in JavaScript environments, and will be excluded 822 + > when compiling natively. 823 + 824 + ```reason 825 + Wonka.interval(10) 826 + |> Wonka.throttle((. _x) => 50) 827 + |> Wonka.take(2) 828 + |> Wonka.subscribe((. x) => print_int(x)); 829 + /* Outputs 0 6 to the console. */ 830 + ``` 831 + 832 + ```typescript 833 + import { pipe, interval, throttle, take, subscribe } from 'wonka'; 834 + 835 + pipe( 836 + interval(10), 837 + throttle(() => 50) 838 + takew(2), 839 + subscribe(val => console.log(val)) 840 + ); // Outputs 0 6 to the console. 841 + ```
+77
docs/api/sinks.md
··· 123 123 124 124 If you have a source that doesn't complete and are looking to resolve on the first 125 125 value instead of the last, you may have to apply `take(1)` to your source. 126 + 127 + ## toObservable 128 + 129 + `toObservable` returns a [spec-compliant JS Observable](https://github.com/tc39/proposal-observable), which emits the same 130 + values as a source. 131 + 132 + As per the specification, the Observable is annotated using `Symbol.observable`. 133 + 134 + > _Note:_ This sink is only available in JavaScript environments, and will be excluded 135 + > when compiling natively. 136 + 137 + ```reason 138 + let observable = Wonka.fromArray([|1, 2, 3|]) 139 + |> Wonka.toObservable; 140 + 141 + observable##subscribe([@bs] { 142 + as _; 143 + pub next = value => print_int(value); 144 + pub complete = () => (); 145 + pub error = _ => (); 146 + }); /* Prints 1 2 3 to the console. */ 147 + ``` 148 + 149 + ```typescript 150 + import { pipe, fromArray, toObservable } from 'wonka'; 151 + 152 + const observable = pipe( 153 + fromArray([1, 2, 3]), 154 + toObservable, 155 + ); 156 + 157 + observable.subscribe({ 158 + next: value => console.log(value), 159 + complete: () => {}, 160 + error: () => {}, 161 + }); // Prints 1 2 3 to the console. 162 + ``` 163 + 164 + ## toCallbag 165 + 166 + `toCallbag` returns a [spec-compliant JS Callbag](https://github.com/callbag/callbag), which emits the same signals 167 + as a Wonka source. 168 + 169 + Since Wonka's sources are very similar to callbags and only diverge from the specification 170 + minimally, Callbags map to Wonka's sources very closely and `toCallbag` only creates a thin 171 + wrapper which is mostly concerned with converting between the type signatures. 172 + 173 + > _Note:_ This sink is only available in JavaScript environments, and will be excluded 174 + > when compiling natively. 175 + 176 + ```reason 177 + /* This example uses the callbag-iterate package for illustrative purposes */ 178 + [@bs.module] external callbagIterate: 179 + (. ('a => unit)) => (. Wonka.callbagT('a)) => unit = "callbag-iterate"; 180 + 181 + let callbag = Wonka.fromArray([|1, 2, 3|]) 182 + |> Wonka.toCallbag; 183 + 184 + callbagIterate(. value => { 185 + print_int(value); 186 + })(. callbag); /* Prints 1 2 3 to the console. */ 187 + ``` 188 + 189 + ```typescript 190 + import { pipe, fromArray, toCallbag } from 'wonka'; 191 + 192 + // This example uses the callbag-iterate package for illustrative purposes 193 + import callbagIterate from 'callbag-iterate'; 194 + 195 + const callbag = pipe( 196 + fromArray([1, 2, 3]), 197 + toCallbag, 198 + ); 199 + 200 + callbagIterate(value => console.log(value))(callbag); 201 + // Prints 1 2 3 to the console. 202 + ```
+109
docs/api/sources.md
··· 188 188 ); // Prints 1 to the console. 189 189 ``` 190 190 191 + ## fromObservable 192 + 193 + `fromObservable` transforms a [spec-compliant JS Observable](https://github.com/tc39/proposal-observable) into a source. 194 + The resulting source will behave exactly the same as the Observable that it was 195 + passed, so it will start, end, and push values identically. 196 + 197 + > _Note:_ This source is only available in JavaScript environments, and will be excluded 198 + > when compiling natively. 199 + 200 + ```typescript 201 + import { pipe, fromObservable, subscribe } from 'wonka'; 202 + 203 + // This example uses zen-observable for illustrative purposes 204 + import Observable from 'zen-observable'; 205 + 206 + const observable = Observable.from([1, 2, 3]); 207 + 208 + pipe( 209 + fromObservable(observable), 210 + subscribe(e => console.log(e)) 211 + ); // Prints 1 2 3 to the console 212 + ``` 213 + 214 + If you're using Reason in a JavaScript environment and you're interested in this 215 + operator, you may be using a library to create or get Observables. 216 + 217 + Some libraries don't expose Observables with the same BuckleScript type signature 218 + that Wonka uses to type them. So while Wonka's `observableT` type is fairly 219 + lenient it may not work for you. 220 + 221 + ```reason 222 + type observableT('a) = {. 223 + [@bs.meth] "subscribe": observerT('a) => subscriptionT 224 + }; 225 + ``` 226 + 227 + To work around this you can create a function that casts your observable type 228 + to Wonka's `observableT`. 229 + 230 + ```reason 231 + type yourObservableType('a); 232 + external asObservable: yourObservableType('a) => Wonka.observableT('a) = "%identity"; 233 + ``` 234 + 235 + This snippet would create an `asObservable` function, which can type-cast your 236 + Observable type to `Wonka.observableT` and compiles away completely. 237 + 238 + ## fromCallbag 239 + 240 + `fromCallbag` transforms a [spec-compliant JS Callbag](https://github.com/callbag/callbag) into a source. 241 + 242 + Since Wonka's sources are very similar to callbags and only diverge from the specification 243 + minimally, Callbags map to Wonka's sources very closely and the `fromCallbag` wrapper 244 + is very thin and mostly concerned with converting between the type signatures. 245 + 246 + > _Note:_ This source is only available in JavaScript environments, and will be excluded 247 + > when compiling natively. 248 + 249 + ```reason 250 + /* This example uses the callbag-from-iter package for illustrative purposes */ 251 + [@bs.module] external callbagFromArray: 252 + array('a) => Wonka.callbagT('a) = "callbag-from-iter"; 253 + 254 + let callbag = callbagFromArray([|1, 2, 3|]); 255 + 256 + Wonka.fromCallbag(callbag) 257 + |> Wonka.subscribe((. x) => Js.log(x)); 258 + /* Prints 1 2 3 to the console. */ 259 + ``` 260 + 261 + ```typescript 262 + import { pipe, fromCallbag, subscribe } from 'wonka'; 263 + 264 + // This example uses the callbag-from-iter package for illustrative purposes 265 + import callbagFromArray from 'callbag-from-iter'; 266 + 267 + const callbag = callbagFromArray([1, 2, 3]); 268 + 269 + pipe( 270 + fromCallbag(callbag), 271 + subscribe(e => console.log(e)) 272 + ); // Prints 1 2 3 to the console. 273 + ``` 274 + 275 + ## interval 276 + 277 + `interval` creates a source that emits values after the given amount of milliseconds. 278 + Internally it uses `setInterval` to accomplish this. 279 + 280 + > _Note:_ This source is only available in JavaScript environments, and will be excluded 281 + > when compiling natively. 282 + 283 + ```reason 284 + Wonka.interval(50) 285 + |> Wonka.subscribe((. x) => Js.log(x)); 286 + /* Prints 0 1 2... to the console. */ 287 + /* The incrementing number is logged every 50ms */ 288 + ``` 289 + 290 + ```typescript 291 + import { pipe, interval, subscribe } from 'wonka'; 292 + 293 + pipe( 294 + interval(50), 295 + subscribe(e => console.log(e)) 296 + ); // Prints 0 1 2... to the console. 297 + // The incrementing number is logged every 50ms 298 + ``` 299 + 191 300 ## empty 192 301 193 302 This is a source that doesn't emit any values when subscribed to and
+17
docs/getting-started.md
··· 117 117 118 118 It's worth noting that most callbacks in Wonka need to be explicitly uncurried, since 119 119 this will help them compile cleanly to JavaScript. 120 + 121 + ## Interoperability 122 + 123 + In JavaScript environments, Wonka comes with several utilities that make it easier 124 + to interoperate with JavaScript primitives and other libraries: 125 + 126 + - [`fromPromise`](./api/sources.md#frompromise) & [`toPromise`](./api/sinks.md#topromise) can be used to interoperate with Promises 127 + - [`fromObservable`](./api/sources.md#fromobservable) & [`toObservable`](./api/sinks.md#toobservable) can be used to interoperate with spec-compliant Observables 128 + - [`fromCallbag`](./api/sources.md#fromcallbag) & [`toCallbag`](./api/sinks.md#tocallbag) can be used to interoperate with spec-compliant Callbags 129 + 130 + Furthermore there are a couple of operators that only work in JavaScript environments 131 + since they need timing primitives, like `setTimeout` and `setInterval`: 132 + 133 + - [`delay`](./api/operators.md#delay) 134 + - [`debounce`](./api/operators.md#debounce) 135 + - [`throttle`](./api/operators.md#throttle) 136 + - [`interval`](./api/sources.md#interval)
+1 -2
src/web/wonkaJs.d.ts
··· 1 1 /* operators */ 2 2 export * from './wonka_operator_debounce'; 3 3 export * from './wonka_operator_delay'; 4 - export * from './wonka_operator_interval'; 5 - export * from './wonka_operator_sample'; 6 4 export * from './wonka_operator_throttle'; 7 5 8 6 /* sinks */ 9 7 export * from './wonka_sink_toPromise'; 10 8 11 9 /* sources */ 10 + export * from './wonka_source_interval'; 12 11 export * from './wonka_source_fromDomEvent'; 13 12 export * from './wonka_source_fromListener'; 14 13 export * from './wonka_source_fromPromise';
+1 -2
src/web/wonkaJs.re
··· 1 1 /* operators */ 2 2 include Wonka_operator_debounce; 3 3 include Wonka_operator_delay; 4 - include Wonka_operator_interval; 5 - include Wonka_operator_sample; 6 4 include Wonka_operator_throttle; 7 5 8 6 /* sinks */ 9 7 include Wonka_sink_toPromise; 10 8 11 9 /* sources */ 10 + include Wonka_source_interval; 12 11 include Wonka_source_fromDomEvent; 13 12 include Wonka_source_fromListener; 14 13 include Wonka_source_fromPromise;
src/web/wonka_operator_interval.d.ts src/web/wonka_source_interval.d.ts
src/web/wonka_operator_interval.re src/web/wonka_source_interval.re
src/web/wonka_operator_interval.rei src/web/wonka_source_interval.rei
src/web/wonka_operator_sample.d.ts src/operators/wonka_operator_sample.d.ts
src/web/wonka_operator_sample.re src/operators/wonka_operator_sample.re
src/web/wonka_operator_sample.rei src/operators/wonka_operator_sample.rei
+1
src/wonka.d.ts
··· 16 16 export * from './operators/wonka_operator_onEnd'; 17 17 export * from './operators/wonka_operator_onPush'; 18 18 export * from './operators/wonka_operator_onStart'; 19 + export * from './operators/wonka_operator_sample'; 19 20 export * from './operators/wonka_operator_scan'; 20 21 export * from './operators/wonka_operator_share'; 21 22 export * from './operators/wonka_operator_skip';
+1
src/wonka_operators.re
··· 7 7 include Wonka_operator_onEnd; 8 8 include Wonka_operator_onPush; 9 9 include Wonka_operator_onStart; 10 + include Wonka_operator_sample; 10 11 include Wonka_operator_scan; 11 12 include Wonka_operator_share; 12 13 include Wonka_operator_skip;