@cascateer/core 2.2.33 → 2.3.1
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/package.json +1 -1
- package/src/lib/ExtendableDictionary.ts +10 -8
- package/src/multicast.ts +2 -2
- package/src/observable/index.ts +0 -1
- package/src/operators/{concat.ts → accumulate.ts} +1 -1
- package/src/operators/exchangeWith.ts +5 -10
- package/src/operators/index.ts +1 -1
- package/src/types.ts +2 -2
- package/src/observable/Future.ts +0 -17
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Dictionary } from "lodash";
|
|
2
|
-
import { UnaryFunction } from "rxjs";
|
|
3
|
-
import { Future } from "../observable";
|
|
1
|
+
import { Dictionary, once } from "lodash";
|
|
2
|
+
import { AsyncSubject, lastValueFrom, UnaryFunction } from "rxjs";
|
|
4
3
|
import { keys } from "./keys";
|
|
5
4
|
|
|
6
5
|
export type Extend<T, U> = Omit<T, keyof U> & U;
|
|
@@ -8,12 +7,15 @@ export type Extend<T, U> = Omit<T, keyof U> & U;
|
|
|
8
7
|
export class ExtendableDictionary<T, U extends Dictionary<T>> {
|
|
9
8
|
constructor(
|
|
10
9
|
public currentValue: U,
|
|
11
|
-
private value = new
|
|
10
|
+
private value = new AsyncSubject<Dictionary<T>>(),
|
|
12
11
|
) {}
|
|
13
12
|
|
|
14
|
-
complete(): U {
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
complete = once((): U => {
|
|
14
|
+
this.value.next(this.currentValue);
|
|
15
|
+
this.value.complete();
|
|
16
|
+
|
|
17
|
+
return this.currentValue;
|
|
18
|
+
});
|
|
17
19
|
|
|
18
20
|
extend<V extends Dictionary<T>>(
|
|
19
21
|
value: (
|
|
@@ -30,7 +32,7 @@ export class ExtendableDictionary<T, U extends Dictionary<T>> {
|
|
|
30
32
|
...value(this.currentValue)({
|
|
31
33
|
property: (constructor) => {
|
|
32
34
|
const property = constructor(
|
|
33
|
-
this.value.
|
|
35
|
+
lastValueFrom(this.value).then(
|
|
34
36
|
(value) =>
|
|
35
37
|
new Promise<string>((resolve, reject) => {
|
|
36
38
|
for (const key of keys(value)) {
|
package/src/multicast.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import { v4 } from "uuid";
|
|
14
14
|
import { property } from "./lib";
|
|
15
15
|
import {
|
|
16
|
-
|
|
16
|
+
accumulate,
|
|
17
17
|
exchangeWith,
|
|
18
18
|
flatMap,
|
|
19
19
|
MulticastActionMessage,
|
|
@@ -93,7 +93,7 @@ self.addEventListener("connect", ({ ports }) => {
|
|
|
93
93
|
map(({ origin, ...message }) => message),
|
|
94
94
|
exchangeWith<MulticastClientMessage, MulticastActionMessage<any>>(port),
|
|
95
95
|
map((message) => ({ ...message, origin: port })),
|
|
96
|
-
|
|
96
|
+
accumulate(),
|
|
97
97
|
flatMap((messages) =>
|
|
98
98
|
thru(
|
|
99
99
|
partition(messages, (message) => message.type === "connect"),
|
package/src/observable/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fromEvent, map, Observable, OperatorFunction
|
|
1
|
+
import { fromEvent, map, Observable, OperatorFunction } from "rxjs";
|
|
2
2
|
import { property } from "../lib";
|
|
3
3
|
|
|
4
4
|
export const exchangeWith =
|
|
@@ -8,10 +8,7 @@ export const exchangeWith =
|
|
|
8
8
|
(messages) =>
|
|
9
9
|
new Observable<InMessage>((subscriber) => {
|
|
10
10
|
fromEvent<MessageEvent<any>>(port, "message")
|
|
11
|
-
.pipe(
|
|
12
|
-
tap((message) => console.log("exchange-in", message)),
|
|
13
|
-
map(property("data")),
|
|
14
|
-
)
|
|
11
|
+
.pipe(map(property("data")))
|
|
15
12
|
.subscribe(subscriber);
|
|
16
13
|
|
|
17
14
|
port.start();
|
|
@@ -20,9 +17,7 @@ export const exchangeWith =
|
|
|
20
17
|
unsubscribe: () => port.close(),
|
|
21
18
|
});
|
|
22
19
|
|
|
23
|
-
return messages
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
next: (message) => port.postMessage(message),
|
|
27
|
-
});
|
|
20
|
+
return messages.subscribe({
|
|
21
|
+
next: (message) => port.postMessage(message),
|
|
22
|
+
});
|
|
28
23
|
});
|
package/src/operators/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Observable } from "rxjs/internal/Observable";
|
|
|
4
4
|
import { ObservableInput } from "rxjs/internal/types";
|
|
5
5
|
import { memoizeHashed } from "./lib/memoizeHashed";
|
|
6
6
|
import { ProxyObservable } from "./observable";
|
|
7
|
-
import {
|
|
7
|
+
import { accumulate, every, some } from "./operators";
|
|
8
8
|
|
|
9
9
|
export interface Effect<Args, Result> extends UnaryFunction<
|
|
10
10
|
Args,
|
|
@@ -51,7 +51,7 @@ export class ProxyEffectInterceptor extends ReplaySubject<
|
|
|
51
51
|
return (args) =>
|
|
52
52
|
new ProxyObservable(effect(args), () =>
|
|
53
53
|
this.pipe(
|
|
54
|
-
|
|
54
|
+
accumulate(),
|
|
55
55
|
switchMap((sources) =>
|
|
56
56
|
combineLatest(sources.map((source) => source.pending)),
|
|
57
57
|
),
|
package/src/observable/Future.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { once } from "lodash";
|
|
2
|
-
import { AsyncSubject, lastValueFrom, UnaryFunction } from "rxjs";
|
|
3
|
-
|
|
4
|
-
export class Future<T> extends AsyncSubject<T> {
|
|
5
|
-
completeWith = once(<U extends T>(value: U): U => {
|
|
6
|
-
this.next(value);
|
|
7
|
-
this.complete();
|
|
8
|
-
|
|
9
|
-
return value;
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
once<U>(predicate: UnaryFunction<T, U | PromiseLike<U>>): Promise<U> {
|
|
13
|
-
return lastValueFrom(this).then(predicate);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
then = this.once;
|
|
17
|
-
}
|