@thi.ng/rstream 7.2.30 → 7.2.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -1
- package/README.md +9 -19
- package/api.d.ts +4 -4
- package/atom.d.ts +8 -7
- package/atom.js +8 -7
- package/forkjoin.d.ts +1 -1
- package/merge.d.ts +7 -5
- package/merge.js +7 -5
- package/object.d.ts +4 -3
- package/package.json +20 -16
- package/pubsub.d.ts +4 -3
- package/pubsub.js +4 -3
- package/stream.d.ts +19 -20
- package/subscription.d.ts +28 -28
- package/subscription.js +24 -24
- package/sync.d.ts +4 -4
- package/sync.js +3 -3
- package/tunnel.d.ts +3 -3
- package/view.d.ts +17 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2022-
|
|
3
|
+
- **Last updated**: 2022-12-20T16:33:11Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
### [7.2.31](https://github.com/thi-ng/umbrella/tree/@thi.ng/rstream@7.2.31) (2022-12-16)
|
|
13
|
+
|
|
14
|
+
#### 🩹 Bug fixes
|
|
15
|
+
|
|
16
|
+
- (TS4.9 regression) update defWorker(), add explicit typehint ([bce5df7](https://github.com/thi-ng/umbrella/commit/bce5df7))
|
|
17
|
+
|
|
12
18
|
### [7.2.7](https://github.com/thi-ng/umbrella/tree/@thi.ng/rstream@7.2.7) (2022-06-09)
|
|
13
19
|
|
|
14
20
|
#### ♻️ Refactoring
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<!-- This file is generated - DO NOT EDIT! -->
|
|
2
2
|
|
|
3
|
-
# 
|
|
3
|
+
# 
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@thi.ng/rstream)
|
|
6
6
|

|
|
7
|
-
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
This project is part of the
|
|
10
10
|
[@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo.
|
|
@@ -41,13 +41,11 @@ This project is part of the
|
|
|
41
41
|
- [Other subscription ops](#other-subscription-ops)
|
|
42
42
|
- [Error handling](#error-handling)
|
|
43
43
|
- [Authors](#authors)
|
|
44
|
-
- [Maintainer](#maintainer)
|
|
45
|
-
- [Contributors](#contributors)
|
|
46
44
|
- [License](#license)
|
|
47
45
|
|
|
48
46
|
## About
|
|
49
47
|
|
|
50
|
-
Reactive streams & subscription primitives for constructing dataflow graphs / pipelines
|
|
48
|
+
Reactive streams & subscription primitives for constructing dataflow graphs / pipelines
|
|
51
49
|
|
|
52
50
|
This library provides & uses three key building blocks for reactive
|
|
53
51
|
programming:
|
|
@@ -194,11 +192,8 @@ ES module import:
|
|
|
194
192
|
|
|
195
193
|
For Node.js REPL:
|
|
196
194
|
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
node --experimental-repl-await
|
|
200
|
-
|
|
201
|
-
> const rstream = await import("@thi.ng/rstream");
|
|
195
|
+
```js
|
|
196
|
+
const rstream = await import("@thi.ng/rstream");
|
|
202
197
|
```
|
|
203
198
|
|
|
204
199
|
Package sizes (brotli'd, pre-treeshake): ESM: 5.60 KB
|
|
@@ -878,14 +873,9 @@ src.next(2)
|
|
|
878
873
|
|
|
879
874
|
## Authors
|
|
880
875
|
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
-
|
|
884
|
-
|
|
885
|
-
### Contributors
|
|
886
|
-
|
|
887
|
-
- André Wachter ([@andrew8er](https://github.com/andrew8er))
|
|
888
|
-
- Gavin Cannizzaro ([@gavinpc-mindgrub](https://github.com/gavinpc-mindgrub))
|
|
876
|
+
- [Karsten Schmidt](https://thi.ng) (Main author)
|
|
877
|
+
- [André Wachter](https://github.com/andrew8er)
|
|
878
|
+
- [Gavin Cannizzaro](https://github.com/gavinpc-mindgrub)
|
|
889
879
|
|
|
890
880
|
If this project contributes to an academic publication, please cite it as:
|
|
891
881
|
|
|
@@ -900,4 +890,4 @@ If this project contributes to an academic publication, please cite it as:
|
|
|
900
890
|
|
|
901
891
|
## License
|
|
902
892
|
|
|
903
|
-
© 2017 - 2022 Karsten Schmidt // Apache
|
|
893
|
+
© 2017 - 2022 Karsten Schmidt // Apache License 2.0
|
package/api.d.ts
CHANGED
|
@@ -72,7 +72,7 @@ export interface WithTransform<A, B> {
|
|
|
72
72
|
}
|
|
73
73
|
export interface TransformableOpts<A, B> extends CommonOpts, WithTransform<A, B> {
|
|
74
74
|
}
|
|
75
|
-
export
|
|
75
|
+
export type ErrorHandler = Fn<any, boolean>;
|
|
76
76
|
export interface WithErrorHandler {
|
|
77
77
|
/**
|
|
78
78
|
* Optional error handler to use for this
|
|
@@ -181,7 +181,7 @@ export interface ISubscription<A, B> extends IDeref<B | undefined>, ISubscriber<
|
|
|
181
181
|
export interface IStream<T> extends ISubscriber<T> {
|
|
182
182
|
cancel: StreamCancel;
|
|
183
183
|
}
|
|
184
|
-
export
|
|
185
|
-
export
|
|
186
|
-
export
|
|
184
|
+
export type StreamCancel = () => void;
|
|
185
|
+
export type StreamSource<T> = (sub: Stream<T>) => StreamCancel | void;
|
|
186
|
+
export type WorkerSource = Worker | Blob | Fn0<Worker> | string;
|
|
187
187
|
//# sourceMappingURL=api.d.ts.map
|
package/atom.d.ts
CHANGED
|
@@ -18,15 +18,16 @@ export interface FromAtomOpts<T> extends CommonOpts {
|
|
|
18
18
|
changed: Predicate2<T>;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* Yields {@link Stream} of value changes in given
|
|
22
|
-
*
|
|
21
|
+
* Yields {@link Stream} of value changes in given [Atom-like state
|
|
22
|
+
* container](https://thi.ng/atom).
|
|
23
23
|
*
|
|
24
24
|
* @remarks
|
|
25
|
-
* Attaches a
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
25
|
+
* [Attaches a
|
|
26
|
+
* watch](https://docs.thi.ng/umbrella/api/interfaces/IWatch.html#addWatch) to
|
|
27
|
+
* the atom and checks for value changes with given `changed` predicate (`!==`
|
|
28
|
+
* by default). If the predicate returns truthy result, the new value is emitted
|
|
29
|
+
* on the stream. If `emitFirst` is true (default), also emits atom's current
|
|
30
|
+
* value when first subscriber attaches to stream.
|
|
30
31
|
*
|
|
31
32
|
* Also see {@link fromView}, {@link fromViewUnsafe}
|
|
32
33
|
*
|
package/atom.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { __optsWithID } from "./idgen.js";
|
|
2
2
|
import { stream } from "./stream.js";
|
|
3
3
|
/**
|
|
4
|
-
* Yields {@link Stream} of value changes in given
|
|
5
|
-
*
|
|
4
|
+
* Yields {@link Stream} of value changes in given [Atom-like state
|
|
5
|
+
* container](https://thi.ng/atom).
|
|
6
6
|
*
|
|
7
7
|
* @remarks
|
|
8
|
-
* Attaches a
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
8
|
+
* [Attaches a
|
|
9
|
+
* watch](https://docs.thi.ng/umbrella/api/interfaces/IWatch.html#addWatch) to
|
|
10
|
+
* the atom and checks for value changes with given `changed` predicate (`!==`
|
|
11
|
+
* by default). If the predicate returns truthy result, the new value is emitted
|
|
12
|
+
* on the stream. If `emitFirst` is true (default), also emits atom's current
|
|
13
|
+
* value when first subscriber attaches to stream.
|
|
13
14
|
*
|
|
14
15
|
* Also see {@link fromView}, {@link fromViewUnsafe}
|
|
15
16
|
*
|
package/forkjoin.d.ts
CHANGED
|
@@ -103,7 +103,7 @@ export interface ForkJoinOpts<IN, MSG, RES, OUT> extends Partial<CommonOpts> {
|
|
|
103
103
|
* @param opts -
|
|
104
104
|
*/
|
|
105
105
|
export declare const forkJoin: <IN, MSG, RES, OUT>(opts: ForkJoinOpts<IN, MSG, RES, OUT>) => Subscription<any, OUT>;
|
|
106
|
-
|
|
106
|
+
type Sliceable<T> = ArrayLike<T> & {
|
|
107
107
|
slice(a: number, b?: number): Sliceable<T>;
|
|
108
108
|
};
|
|
109
109
|
/**
|
package/merge.d.ts
CHANGED
|
@@ -11,9 +11,9 @@ export interface StreamMergeOpts<A, B> extends TransformableOpts<A, B> {
|
|
|
11
11
|
* multiple inputs and passing received values on to any subscribers.
|
|
12
12
|
*
|
|
13
13
|
* @remarks
|
|
14
|
-
* Input streams can be added and removed dynamically. By default,
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* Input streams can be added and removed dynamically. By default, `StreamMerge`
|
|
15
|
+
* calls {@link ISubscriber.done} when the last active input is done, but this
|
|
16
|
+
* behavior can be overridden via the provided
|
|
17
17
|
* {@link StreamMergeOpts | options}.
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
@@ -38,8 +38,10 @@ export interface StreamMergeOpts<A, B> extends TransformableOpts<A, B> {
|
|
|
38
38
|
* ```
|
|
39
39
|
*
|
|
40
40
|
* @example
|
|
41
|
-
* Use the
|
|
42
|
-
*
|
|
41
|
+
* Use the
|
|
42
|
+
* [`labeled()`](https://docs.thi.ng/umbrella/transducers/functions/labeled.html)
|
|
43
|
+
* transducer for each input to create a stream of labeled values and
|
|
44
|
+
* track their provenance:
|
|
43
45
|
*
|
|
44
46
|
* @example
|
|
45
47
|
* ```ts
|
package/merge.js
CHANGED
|
@@ -8,9 +8,9 @@ import { Subscription } from "./subscription.js";
|
|
|
8
8
|
* multiple inputs and passing received values on to any subscribers.
|
|
9
9
|
*
|
|
10
10
|
* @remarks
|
|
11
|
-
* Input streams can be added and removed dynamically. By default,
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* Input streams can be added and removed dynamically. By default, `StreamMerge`
|
|
12
|
+
* calls {@link ISubscriber.done} when the last active input is done, but this
|
|
13
|
+
* behavior can be overridden via the provided
|
|
14
14
|
* {@link StreamMergeOpts | options}.
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
@@ -35,8 +35,10 @@ import { Subscription } from "./subscription.js";
|
|
|
35
35
|
* ```
|
|
36
36
|
*
|
|
37
37
|
* @example
|
|
38
|
-
* Use the
|
|
39
|
-
*
|
|
38
|
+
* Use the
|
|
39
|
+
* [`labeled()`](https://docs.thi.ng/umbrella/transducers/functions/labeled.html)
|
|
40
|
+
* transducer for each input to create a stream of labeled values and
|
|
41
|
+
* track their provenance:
|
|
40
42
|
*
|
|
41
43
|
* @example
|
|
42
44
|
* ```ts
|
package/object.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Keys, Predicate2 } from "@thi.ng/api";
|
|
2
2
|
import type { CommonOpts } from "./api.js";
|
|
3
3
|
import { Subscription } from "./subscription.js";
|
|
4
|
-
export
|
|
4
|
+
export type KeyStreams<T, K extends Keys<T>> = {
|
|
5
5
|
[id in K]-?: Subscription<T[id], T[id]>;
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
@@ -43,8 +43,9 @@ export interface StreamObjOpts<T, K extends Keys<T>> extends CommonOpts {
|
|
|
43
43
|
*/
|
|
44
44
|
defaults: Partial<T>;
|
|
45
45
|
/**
|
|
46
|
-
* If true, attaches
|
|
47
|
-
*
|
|
46
|
+
* If true, attaches
|
|
47
|
+
* [`dedupe()`](https://docs.thi.ng/umbrella/transducers/functions/dedupe.html)
|
|
48
|
+
* transducer to each key's value stream to avoid obsolete downstream
|
|
48
49
|
* propagation when a key's value hasn't actually changed.
|
|
49
50
|
*
|
|
50
51
|
* @defaultValue true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/rstream",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.32",
|
|
4
4
|
"description": "Reactive streams & subscription primitives for constructing dataflow graphs / pipelines",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -21,11 +21,15 @@
|
|
|
21
21
|
"url": "https://patreon.com/thing_umbrella"
|
|
22
22
|
}
|
|
23
23
|
],
|
|
24
|
-
"author": "Karsten Schmidt
|
|
24
|
+
"author": "Karsten Schmidt (https://thi.ng)",
|
|
25
|
+
"contributors": [
|
|
26
|
+
"André Wachter (https://github.com/andrew8er)",
|
|
27
|
+
"Gavin Cannizzaro (https://github.com/gavinpc-mindgrub)"
|
|
28
|
+
],
|
|
25
29
|
"license": "Apache-2.0",
|
|
26
30
|
"scripts": {
|
|
27
31
|
"build": "yarn clean && tsc --declaration",
|
|
28
|
-
"clean": "rimraf '*.js' '*.d.ts' '*.map' doc",
|
|
32
|
+
"clean": "rimraf '*.js' '*.d.ts' '*.map' doc internal",
|
|
29
33
|
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
|
|
30
34
|
"doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
|
|
31
35
|
"doc:readme": "yarn doc:stats && tools:readme",
|
|
@@ -34,22 +38,22 @@
|
|
|
34
38
|
"test": "testament test"
|
|
35
39
|
},
|
|
36
40
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.
|
|
38
|
-
"@thi.ng/arrays": "^2.4.
|
|
39
|
-
"@thi.ng/associative": "^6.2.
|
|
40
|
-
"@thi.ng/atom": "^5.1.
|
|
41
|
-
"@thi.ng/checks": "^3.3.
|
|
42
|
-
"@thi.ng/errors": "^2.2.
|
|
43
|
-
"@thi.ng/logger": "^1.4.
|
|
44
|
-
"@thi.ng/transducers": "^8.3.
|
|
41
|
+
"@thi.ng/api": "^8.6.1",
|
|
42
|
+
"@thi.ng/arrays": "^2.4.6",
|
|
43
|
+
"@thi.ng/associative": "^6.2.20",
|
|
44
|
+
"@thi.ng/atom": "^5.1.26",
|
|
45
|
+
"@thi.ng/checks": "^3.3.5",
|
|
46
|
+
"@thi.ng/errors": "^2.2.6",
|
|
47
|
+
"@thi.ng/logger": "^1.4.5",
|
|
48
|
+
"@thi.ng/transducers": "^8.3.27"
|
|
45
49
|
},
|
|
46
50
|
"devDependencies": {
|
|
47
|
-
"@microsoft/api-extractor": "^7.33.
|
|
48
|
-
"@thi.ng/testament": "^0.3.
|
|
51
|
+
"@microsoft/api-extractor": "^7.33.7",
|
|
52
|
+
"@thi.ng/testament": "^0.3.7",
|
|
49
53
|
"rimraf": "^3.0.2",
|
|
50
54
|
"tools": "^0.0.1",
|
|
51
|
-
"typedoc": "^0.23.
|
|
52
|
-
"typescript": "^4.
|
|
55
|
+
"typedoc": "^0.23.22",
|
|
56
|
+
"typescript": "^4.9.4"
|
|
53
57
|
},
|
|
54
58
|
"keywords": [
|
|
55
59
|
"async",
|
|
@@ -201,5 +205,5 @@
|
|
|
201
205
|
],
|
|
202
206
|
"year": 2017
|
|
203
207
|
},
|
|
204
|
-
"gitHead": "
|
|
208
|
+
"gitHead": "7b2af448da8a63fb21704a79cc4cdf1f3d7d7a64\n"
|
|
205
209
|
}
|
package/pubsub.d.ts
CHANGED
|
@@ -33,9 +33,10 @@ export interface PubSubOpts<A, B, T> {
|
|
|
33
33
|
* The actual topic (return value from `topic` fn) can be of any type `T`, or
|
|
34
34
|
* `undefined`. If the latter is returned, the incoming value will not be
|
|
35
35
|
* processed further. Complex topics (e.g objects / arrays) are allowed and
|
|
36
|
-
* they're matched against registered topics using
|
|
37
|
-
*
|
|
38
|
-
*
|
|
36
|
+
* they're matched against registered topics using
|
|
37
|
+
* [`equiv()`](https://docs.thi.ng/umbrella/equiv/functions/equiv.html) by
|
|
38
|
+
* default (but customizable via `equiv` option). Each topic can have any number
|
|
39
|
+
* of subscribers.
|
|
39
40
|
*
|
|
40
41
|
* If a `xform` transducer is given, it is always applied prior to passing the
|
|
41
42
|
* input to the topic function. I.e. in this case the topic function will
|
package/pubsub.js
CHANGED
|
@@ -12,9 +12,10 @@ import { Subscription, subscription } from "./subscription.js";
|
|
|
12
12
|
* The actual topic (return value from `topic` fn) can be of any type `T`, or
|
|
13
13
|
* `undefined`. If the latter is returned, the incoming value will not be
|
|
14
14
|
* processed further. Complex topics (e.g objects / arrays) are allowed and
|
|
15
|
-
* they're matched against registered topics using
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* they're matched against registered topics using
|
|
16
|
+
* [`equiv()`](https://docs.thi.ng/umbrella/equiv/functions/equiv.html) by
|
|
17
|
+
* default (but customizable via `equiv` option). Each topic can have any number
|
|
18
|
+
* of subscribers.
|
|
18
19
|
*
|
|
19
20
|
* If a `xform` transducer is given, it is always applied prior to passing the
|
|
20
21
|
* input to the topic function. I.e. in this case the topic function will
|
package/stream.d.ts
CHANGED
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
import { CommonOpts, IStream, ISubscriber, ISubscription, StreamCancel, StreamSource, TransformableOpts, WithErrorHandlerOpts } from "./api.js";
|
|
2
2
|
import { Subscription } from "./subscription.js";
|
|
3
3
|
/**
|
|
4
|
-
* Creates a new {@link Stream} instance, optionally with given
|
|
5
|
-
*
|
|
4
|
+
* Creates a new {@link Stream} instance, optionally with given `StreamSource`
|
|
5
|
+
* function and / or options.
|
|
6
6
|
*
|
|
7
7
|
* @remarks
|
|
8
|
-
* If a `src` function is provided, the function will be only called
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* value propagation.
|
|
8
|
+
* If a `src` function is provided, the function will be only called (with the
|
|
9
|
+
* `Stream` instance as single argument) once the first subscriber has attached
|
|
10
|
+
* to the stream. If the function returns another function, it will be used for
|
|
11
|
+
* cleanup purposes if the stream is cancelled, e.g. if the first / last
|
|
12
|
+
* subscriber has unsubscribed (depending on `closeOut` option). Streams are
|
|
13
|
+
* intended as (primarily async) data sources in a dataflow graph and are the
|
|
14
|
+
* primary construct for the various `from*()` functions provided by this
|
|
15
|
+
* package. However, streams can also be triggered manually (from outside the
|
|
16
|
+
* stream), in which case the user should call `stream.next()` to cause value
|
|
17
|
+
* propagation.
|
|
19
18
|
*
|
|
20
19
|
* Streams (like {@link Subscription}) implement the
|
|
21
|
-
*
|
|
22
|
-
* stream's last received value. This is useful
|
|
23
|
-
* e.g. in combination with
|
|
24
|
-
* supports direct embedding of
|
|
25
|
-
* components (and will be deref them
|
|
26
|
-
* not yet emitted a value, value caching is
|
|
27
|
-
* is done, it will deref to `undefined`.
|
|
20
|
+
* [`IDeref`](https://docs.thi.ng/umbrella/api/interfaces/IDeref.html) interface
|
|
21
|
+
* which provides read access to a stream's last received value. This is useful
|
|
22
|
+
* for various purposes, e.g. in combination with
|
|
23
|
+
* [`thi.ng/hdom`](https://thi.ng/hdom), which supports direct embedding of
|
|
24
|
+
* streams (i.e. their values) into UI components (and will be deref them
|
|
25
|
+
* automatically). If the stream has not yet emitted a value, value caching is
|
|
26
|
+
* disabled or if the stream is done, it will deref to `undefined`.
|
|
28
27
|
*
|
|
29
28
|
* @example
|
|
30
29
|
* ```ts
|
package/subscription.d.ts
CHANGED
|
@@ -3,35 +3,34 @@ import type { Reducer, Transducer } from "@thi.ng/transducers";
|
|
|
3
3
|
import { Reduced } from "@thi.ng/transducers/reduced";
|
|
4
4
|
import { CloseMode, CommonOpts, ISubscriber, ISubscription, State, SubscriptionOpts, TransformableOpts, WithErrorHandlerOpts, WithTransform } from "./api.js";
|
|
5
5
|
/**
|
|
6
|
-
* Creates a new {@link Subscription} instance, the fundamental datatype
|
|
7
|
-
*
|
|
6
|
+
* Creates a new {@link Subscription} instance, the fundamental datatype and
|
|
7
|
+
* building block provided by this package.
|
|
8
8
|
*
|
|
9
9
|
* @remarks
|
|
10
|
-
* Most other types in rstream, including {@link Stream}s, are
|
|
11
|
-
*
|
|
10
|
+
* Most other types in rstream, including {@link Stream}s, are `Subscription`s
|
|
11
|
+
* and all can be:
|
|
12
12
|
*
|
|
13
|
-
* - connected into directed graphs (sync or async & not necessarily
|
|
14
|
-
* DAGs)
|
|
13
|
+
* - connected into directed graphs (sync or async & not necessarily DAGs)
|
|
15
14
|
* - transformed using transducers (incl. support for early termination)
|
|
16
15
|
* - can have any number of subscribers (optionally each w/ their own
|
|
17
16
|
* transducers)
|
|
18
|
-
* - recursively unsubscribe themselves from parent after their last
|
|
19
|
-
*
|
|
20
|
-
* - will go into a non-recoverable error state if none of the
|
|
21
|
-
*
|
|
22
|
-
* - implement the
|
|
17
|
+
* - recursively unsubscribe themselves from parent after their last subscriber
|
|
18
|
+
* unsubscribed (configurable)
|
|
19
|
+
* - will go into a non-recoverable error state if none of the subscribers has
|
|
20
|
+
* an error handler itself
|
|
21
|
+
* - implement the
|
|
22
|
+
* [`IDeref`](https://docs.thi.ng/umbrella/api/interfaces/IDeref.html)
|
|
23
|
+
* interface
|
|
23
24
|
*
|
|
24
|
-
* If a transducer is provided (via the `xform` option), all received
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* overridden).
|
|
25
|
+
* If a transducer is provided (via the `xform` option), all received values
|
|
26
|
+
* will be first processed by the transducer and only its transformed result(s)
|
|
27
|
+
* (if any) will be passed to downstream subscribers. Any uncaught errors
|
|
28
|
+
* *inside* the transducer will cause this subscription's error handler to be
|
|
29
|
+
* called and will stop this subscription from receiving any further values (by
|
|
30
|
+
* default, unless overridden).
|
|
31
31
|
*
|
|
32
|
-
* Subscription behavior can be customized via the additional (optional)
|
|
33
|
-
*
|
|
34
|
-
* further details.
|
|
32
|
+
* Subscription behavior can be customized via the additional (optional) options
|
|
33
|
+
* arg. See {@link CommonOpts} and {@link SubscriptionOpts} for further details.
|
|
35
34
|
*
|
|
36
35
|
* @example
|
|
37
36
|
* ```ts
|
|
@@ -76,10 +75,10 @@ export declare class Subscription<A, B> implements ISubscription<A, B> {
|
|
|
76
75
|
subscribe(sub: Partial<ISubscriber<B>>, opts?: Partial<CommonOpts>): ISubscription<B, B>;
|
|
77
76
|
subscribe<C>(sub: Partial<ISubscriber<C>>, opts?: Partial<TransformableOpts<B, C>>): ISubscription<B, C>;
|
|
78
77
|
/**
|
|
79
|
-
* Creates a new child subscription using given transducers and
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
78
|
+
* Creates a new child subscription using given transducers and optional
|
|
79
|
+
* subscription ID. Supports up to 4 transducers and if more than one
|
|
80
|
+
* transducer is given, composes them in left-to-right order using
|
|
81
|
+
* [`comp()`](https://docs.thi.ng/umbrella/transducers/functions/comp.html).
|
|
83
82
|
*
|
|
84
83
|
* Shorthand for `subscribe(comp(xf1, xf2,...), id)`
|
|
85
84
|
*/
|
|
@@ -89,9 +88,10 @@ export declare class Subscription<A, B> implements ISubscription<A, B> {
|
|
|
89
88
|
transform<C, D, E, F>(a: Transducer<B, C>, b: Transducer<C, D>, c: Transducer<D, E>, d: Transducer<E, F>, opts?: Partial<WithErrorHandlerOpts>): ISubscription<B, F>;
|
|
90
89
|
transform<C>(opts: WithTransform<B, C> & Partial<WithErrorHandlerOpts>): ISubscription<B, C>;
|
|
91
90
|
/**
|
|
92
|
-
* Syntax sugar for {@link Subscription.transform} when using a
|
|
93
|
-
*
|
|
94
|
-
* function `fn` is used as `map`'s
|
|
91
|
+
* Syntax sugar for {@link Subscription.transform} when using a single
|
|
92
|
+
* [`map()`](https://docs.thi.ng/umbrella/transducers/functions/map.html)
|
|
93
|
+
* transducer only. The given function `fn` is used as `map`'s
|
|
94
|
+
* transformation fn.
|
|
95
95
|
*
|
|
96
96
|
* @param fn -
|
|
97
97
|
* @param opts -
|
package/subscription.js
CHANGED
|
@@ -12,35 +12,34 @@ import { CloseMode, State, } from "./api.js";
|
|
|
12
12
|
import { __optsWithID } from "./idgen.js";
|
|
13
13
|
import { LOGGER } from "./logger.js";
|
|
14
14
|
/**
|
|
15
|
-
* Creates a new {@link Subscription} instance, the fundamental datatype
|
|
16
|
-
*
|
|
15
|
+
* Creates a new {@link Subscription} instance, the fundamental datatype and
|
|
16
|
+
* building block provided by this package.
|
|
17
17
|
*
|
|
18
18
|
* @remarks
|
|
19
|
-
* Most other types in rstream, including {@link Stream}s, are
|
|
20
|
-
*
|
|
19
|
+
* Most other types in rstream, including {@link Stream}s, are `Subscription`s
|
|
20
|
+
* and all can be:
|
|
21
21
|
*
|
|
22
|
-
* - connected into directed graphs (sync or async & not necessarily
|
|
23
|
-
* DAGs)
|
|
22
|
+
* - connected into directed graphs (sync or async & not necessarily DAGs)
|
|
24
23
|
* - transformed using transducers (incl. support for early termination)
|
|
25
24
|
* - can have any number of subscribers (optionally each w/ their own
|
|
26
25
|
* transducers)
|
|
27
|
-
* - recursively unsubscribe themselves from parent after their last
|
|
28
|
-
*
|
|
29
|
-
* - will go into a non-recoverable error state if none of the
|
|
30
|
-
*
|
|
31
|
-
* - implement the
|
|
26
|
+
* - recursively unsubscribe themselves from parent after their last subscriber
|
|
27
|
+
* unsubscribed (configurable)
|
|
28
|
+
* - will go into a non-recoverable error state if none of the subscribers has
|
|
29
|
+
* an error handler itself
|
|
30
|
+
* - implement the
|
|
31
|
+
* [`IDeref`](https://docs.thi.ng/umbrella/api/interfaces/IDeref.html)
|
|
32
|
+
* interface
|
|
32
33
|
*
|
|
33
|
-
* If a transducer is provided (via the `xform` option), all received
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* overridden).
|
|
34
|
+
* If a transducer is provided (via the `xform` option), all received values
|
|
35
|
+
* will be first processed by the transducer and only its transformed result(s)
|
|
36
|
+
* (if any) will be passed to downstream subscribers. Any uncaught errors
|
|
37
|
+
* *inside* the transducer will cause this subscription's error handler to be
|
|
38
|
+
* called and will stop this subscription from receiving any further values (by
|
|
39
|
+
* default, unless overridden).
|
|
40
40
|
*
|
|
41
|
-
* Subscription behavior can be customized via the additional (optional)
|
|
42
|
-
*
|
|
43
|
-
* further details.
|
|
41
|
+
* Subscription behavior can be customized via the additional (optional) options
|
|
42
|
+
* arg. See {@link CommonOpts} and {@link SubscriptionOpts} for further details.
|
|
44
43
|
*
|
|
45
44
|
* @example
|
|
46
45
|
* ```ts
|
|
@@ -124,9 +123,10 @@ export class Subscription {
|
|
|
124
123
|
: opts));
|
|
125
124
|
}
|
|
126
125
|
/**
|
|
127
|
-
* Syntax sugar for {@link Subscription.transform} when using a
|
|
128
|
-
*
|
|
129
|
-
* function `fn` is used as `map`'s
|
|
126
|
+
* Syntax sugar for {@link Subscription.transform} when using a single
|
|
127
|
+
* [`map()`](https://docs.thi.ng/umbrella/transducers/functions/map.html)
|
|
128
|
+
* transducer only. The given function `fn` is used as `map`'s
|
|
129
|
+
* transformation fn.
|
|
130
130
|
*
|
|
131
131
|
* @param fn -
|
|
132
132
|
* @param opts -
|
package/sync.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Always, Derefed, IObjectOf } from "@thi.ng/api";
|
|
|
2
2
|
import { PartitionSync } from "@thi.ng/transducers/partition-sync";
|
|
3
3
|
import type { ISubscribable, ISubscription, TransformableOpts } from "./api.js";
|
|
4
4
|
import { Subscription } from "./subscription.js";
|
|
5
|
-
export
|
|
5
|
+
export type SyncTuple<T extends IObjectOf<ISubscribable<any>>> = {
|
|
6
6
|
[id in keyof T]: Always<Derefed<T[id]>>;
|
|
7
7
|
};
|
|
8
8
|
export interface StreamSyncOpts<A extends IObjectOf<ISubscribable<any>>, B = SyncTuple<A>> extends TransformableOpts<SyncTuple<A>, B> {
|
|
@@ -87,9 +87,9 @@ export interface StreamSyncOpts<A extends IObjectOf<ISubscribable<any>>, B = Syn
|
|
|
87
87
|
* option to `false`.
|
|
88
88
|
*
|
|
89
89
|
* The synchronization is done via the
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* function's docs for further details.
|
|
90
|
+
* [`partitionSync()`](https://docs.thi.ng/umbrella/transducers/functions/partitionSync-1.html)
|
|
91
|
+
* transducer from the [`thi.ng/transducers`](https://thi.ng/transducers)
|
|
92
|
+
* package. See this function's docs for further details.
|
|
93
93
|
*
|
|
94
94
|
* @example
|
|
95
95
|
* ```ts
|
package/sync.js
CHANGED
|
@@ -39,9 +39,9 @@ import { Subscription } from "./subscription.js";
|
|
|
39
39
|
* option to `false`.
|
|
40
40
|
*
|
|
41
41
|
* The synchronization is done via the
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* function's docs for further details.
|
|
42
|
+
* [`partitionSync()`](https://docs.thi.ng/umbrella/transducers/functions/partitionSync-1.html)
|
|
43
|
+
* transducer from the [`thi.ng/transducers`](https://thi.ng/transducers)
|
|
44
|
+
* package. See this function's docs for further details.
|
|
45
45
|
*
|
|
46
46
|
* @example
|
|
47
47
|
* ```ts
|
package/tunnel.d.ts
CHANGED
|
@@ -21,9 +21,9 @@ export interface TunnelOpts<A> {
|
|
|
21
21
|
*/
|
|
22
22
|
id?: string;
|
|
23
23
|
/**
|
|
24
|
-
* Optional function to extract transferables from incoming stream
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* Optional function to extract transferables from incoming stream values,
|
|
25
|
+
* e.g. ArrayBuffers. See:
|
|
26
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage
|
|
27
27
|
*/
|
|
28
28
|
transferables?: Fn<A, any[]>;
|
|
29
29
|
/**
|
package/view.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface FromViewOpts<P, A, B> extends Partial<CommonOpts> {
|
|
|
7
7
|
tx?: Fn<A, B>;
|
|
8
8
|
equiv?: Predicate2<A>;
|
|
9
9
|
}
|
|
10
|
-
export
|
|
10
|
+
export type FromViewUnsafeOpts<T> = FromViewOpts<Path, any, T>;
|
|
11
11
|
/**
|
|
12
12
|
* Unchecked version of {@link fromView}. Paths can be given as string
|
|
13
13
|
* or tuple.
|
|
@@ -39,30 +39,31 @@ export declare type FromViewUnsafeOpts<T> = FromViewOpts<Path, any, T>;
|
|
|
39
39
|
*/
|
|
40
40
|
export declare const fromViewUnsafe: <T>(atom: ReadonlyAtom<any>, opts: FromViewUnsafeOpts<T>) => Stream<T extends undefined ? any : T>;
|
|
41
41
|
/**
|
|
42
|
-
* Similar to {@link fromAtom}, but creates a type checked, eager
|
|
43
|
-
*
|
|
44
|
-
*
|
|
42
|
+
* Similar to {@link fromAtom}, but creates a type checked, eager derived view
|
|
43
|
+
* for a nested value in an Atom-like state container and yields stream of its
|
|
44
|
+
* value changes.
|
|
45
45
|
*
|
|
46
46
|
* @remarks
|
|
47
|
-
* Stream value type is inferred from target path or (if given), the
|
|
48
|
-
*
|
|
47
|
+
* Stream value type is inferred from target path or (if given), the result type
|
|
48
|
+
* of the optional view transformer (`tx` option).
|
|
49
49
|
*
|
|
50
|
-
* Views are readonly and more lightweight versions of
|
|
51
|
-
*
|
|
52
|
-
* changes with given `equiv` predicate (default:
|
|
53
|
-
*
|
|
54
|
-
* (i.e. there's a new value), the new value is
|
|
55
|
-
* The first value emitted is always the (possibly
|
|
56
|
-
* value at the stream's start time (i.e. when the first
|
|
57
|
-
* attaches).
|
|
50
|
+
* Views are readonly and more lightweight versions of [thi.ng/atom
|
|
51
|
+
* cursors](https://docs.thi.ng/umbrella/atom/classes/Cursor.html). The view
|
|
52
|
+
* checks for value changes with given `equiv` predicate (default:
|
|
53
|
+
* [`equiv()`](https://docs.thi.ng/umbrella/equiv/functions/equiv.html)). If the
|
|
54
|
+
* predicate returns a falsy result (i.e. there's a new value), the new value is
|
|
55
|
+
* emitted on the stream. The first value emitted is always the (possibly
|
|
56
|
+
* transformed) current value at the stream's start time (i.e. when the first
|
|
57
|
+
* subscriber attaches).
|
|
58
58
|
*
|
|
59
59
|
* If the `tx` option is given, the raw value is first passed to this
|
|
60
60
|
* transformer function and its result emitted on the stream instead.
|
|
61
61
|
*
|
|
62
62
|
* When the stream is cancelled the view is destroyed as well.
|
|
63
63
|
*
|
|
64
|
-
* Also see
|
|
65
|
-
*
|
|
64
|
+
* Also see
|
|
65
|
+
* [`defView()`](https://docs.thi.ng/umbrella/atom/functions/defView.html),
|
|
66
|
+
* [`defViewUnsafe()`](https://docs.thi.ng/umbrella/atom/functions/defViewUnsafe.html)
|
|
66
67
|
*
|
|
67
68
|
* @example
|
|
68
69
|
* ```ts
|