You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,7 @@ The changes mentioned here are discussed in detail in the [release highlights](h
18
18
* Introduced `mobx.configure({ disableErrorBoundaries })`, for easier debugging of exceptoins. By [NaridaL](https://github.com/NaridaL) through [#1262](https://github.com/mobxjs/mobx/pull/1262)
19
19
*`toJS` now accepts the options: `{ detectCycles?: boolean, exportMapsAsObjects?: boolean }`, both `true` by default
20
20
* Introduced `flow` to create a chain of async actions. This is the same function as [`asyncActions`](https://github.com/mobxjs/mobx-utils#asyncaction) of the mobx-utils package
21
+
* These `flow`'s are now cancellable, by calling `.cancel()` on the returned promise, which will throw a cancellation exception into the generator function.
21
22
* The flow typings have been updated. Since this is a manual effort, there can be mistakes, so feel free to PR!
22
23
23
24
*`computed(fn, options?)` / `@computed(options) get fn()` now accept the following options:
exportfunctionflow<A1>(generator: (a1: A1)=>IterableIterator<any>): (a1: A1)=>Promise<any>// Ideally we want to have R instead of Any, but cannot specify R without specifying A1 etc... 'any' as result is better then not specifying request args
): (a1: A1)=>CancellablePromise<any>// Ideally we want to have R instead of Any, but cannot specify R without specifying A1 etc... 'any' as result is better then not specifying request args
): (a1: A1)=>Promise<any>// Ideally we want to have R instead of Any, but cannot specify R without specifying A1 etc... 'any' as result is better then not specifying request args
59
+
): (a1: A1)=>CancellablePromise<any>// Ideally we want to have R instead of Any, but cannot specify R without specifying A1 etc... 'any' as result is better then not specifying request args
* `asyncAction` takes a generator function and automatically wraps all parts of the process in actions. See the examples below.
96
-
* `asyncAction` can be used both as decorator or to wrap functions.
97
-
*
98
-
* - It is important that `asyncAction should always be used with a generator function (recognizable as `function*` or `*name` syntax)
99
-
* - Each yield statement should return a Promise. The generator function will continue as soon as the promise settles, with the settled value
100
-
* - When the generator function finishes, you can return a normal value. The `asyncAction` wrapped function will always produce a promise delivering that value.
101
-
*
102
-
* When using the mobx devTools, an asyncAction will emit `action` events with names like:
103
-
* * `"fetchUsers - runid: 6 - init"`
104
-
* * `"fetchUsers - runid: 6 - yield 0"`
105
-
* * `"fetchUsers - runid: 6 - yield 1"`
106
-
*
107
-
* The `runId` represents the generator instance. In other words, if `fetchUsers` is invoked multiple times concurrently, the events with the same `runid` belong toghether.
108
-
* The `yield` number indicates the progress of the generator. `init` indicates spawning (it won't do anything, but you can find the original arguments of the `asyncAction` here).
109
-
* `yield 0` ... `yield n` indicates the code block that is now being executed. `yield 0` is before the first `yield`, `yield 1` after the first one etc. Note that yield numbers are not determined lexically but by the runtime flow.
110
-
*
111
-
* `asyncActions` requires `Promise` and `generators` to be available on the target environment. Polyfill `Promise` if needed. Both TypeScript and Babel can compile generator functions down to ES5.
112
-
*
113
-
* N.B. due to a [babel limitation](https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy/issues/26), in Babel generatos cannot be combined with decorators. See also [#70](https://github.com/mobxjs/mobx-utils/issues/70)
0 commit comments