Mirror: 馃帺 A tiny but capable push & pull stream library for TypeScript and Flow
1--- 2title: Migration 3order: 2 4--- 5 6This page lists breaking changes and migration guides for 7various major releases of Wonka. 8 9## v6.0.0 10 11In `v6.0.0` of Wonka, we've migrated fully to TypeScript. 12If you're using this project with Reason or OCaml before, we're sorry for 13the inconvenience. However, v4 and v5-rc will remain usable for these 14platforms and languages. 15 16The internal API and data structures of Wonka haven't changed in `v6.0.0` 17compared to the prior releases and are based on `v4.0.14`. This means that 18from a TypeScript, Flow, and JS perspective, `v6.0.0` is backwards compatible 19and continues to function as before. 20 21However, the `fromList` API has been removed so far, and we reserve ourselves 22room to make more breaking changes were behaviour before was broken. 23 24We're also dropping IE11 support and are now bundling against an ES2015 target. 25 26## v4.0.0 27 28In `v4.0.0` of Wonka, we've migrated to BuckleScript v7 and 29`genType` for automatic type generation for TypeScript. The 30Flow types are derived from the automatic types and are generated 31by `flowgen`. 32 33This may mean that `bsb-native` and Dune/Esy builds are temporarily 34broken, as they haven't been tested yet. If so, they will be fixed 35in a future minor release. Please stick with `v3.2.2` if you're having 36trouble. 37 38This release has no breaking changes for Reason/OCaml in terms of 39API changes. You can use the library exactly as you have before. 40 41**For TypeScript and Flow some APIs have changed**. 42 43### New TypeScript and Flow typings 44 45The type for `Subscription`, `Observer`, and `Subject` have changed. 46These used to be exposed as tuples (fixed-size arrays) in the past, 47but are now compiled to objects, due to the upgrade to BuckleScript v7. 48 49If you're using `subscribe`, `makeSubject`, or `make` you will have 50to change some of your types. If you don't, you won't have to update 51any of your code and can even mix Wonka `v4.0.0` with `v3.2.2` in the 52same bundle. 53 54The `Subscription` type has changed from `[() => void]` to 55`{ unsubscribe: (_: void) => void }`: 56 57```ts 58import { subscribe } from 'wonka'; 59 60// Before: 61const [unsubscribe] = subscribe(source); 62// After: 63const { unsubscribe } = subscribe(source); 64``` 65 66The `Observer` type has changed similarly, so you'll have to 67update your code if you're using `make`: 68 69```ts 70import { make } from 'wonka'; 71 72// Before: 73const source = make(([next, complete]) => /* ... */); 74// After: 75const source = make(({ next, complete }) => /* ... */); 76``` 77 78And lastly the `Subject` type has changed as well, so update 79your usage of `makeSubject`: 80 81```ts 82import { makeSubject } from 'wonka'; 83 84// Before: 85const [source, next, complete] = makeSubject(); 86// After: 87const { source, next, complete } = makeSubject(); 88``` 89 90### Improvements 91 92The test suite has been rewritten from scratch to improve our 93testing of some tricky edge cases. In most cases operators have 94been updated to behave more nicely and closer to the spec and 95as expected. This is especially true if you're using synchronous 96sources or iterables a lot. 97 98Wonka has reached a much higher test coverage and operators like 99`merge` and `switchMap` will now behave as expected with synchronous 100sources. 101 102This is the list of operators that have changed. If your code has 103been working before, you _shouldn't see any different behaviour_. 104The changed operators will simply have received bugfixes and will 105behave more predictably (and hopefully correctly) in certain edge cases! 106 107- [`buffer`](./api/operators.md#buffer) 108- [`combine`](./api/operators.md#combine) 109- [`debounce`](./api/operators.md#debounce) 110- [`delay`](./api/operators.md#delay) 111- [`sample`](./api/operators.md#sample) 112- [`skipUntil`](./api/operators.md#skipuntil) 113- [`take`](./api/operators.md#take) 114- [`takeLast`](./api/operators.md#takelast) 115- [`takeWhile`](./api/operators.md#takewhile) 116- [`switchMap`](./api/operators.md#switchmap) 117- [`mergeMap`](./api/operators.md#mergemap) 118- [`concatMap`](./api/operators.md#concatmap) 119- [`switchAll`](./api/operators.md#switchall) 120- [`mergeAll`](./api/operators.md#mergeall) 121- [`concatAll`](./api/operators.md#concatall) 122- [`merge`](./api/operators.md#merge) 123- [`concat`](./api/operators.md#concat) 124 125The `take` operator is the only one that has been changed to fix 126a notable new usage case. It can now accept a maximum of `0` or below, 127to close the source immediately.