@cascateer/core 2.0.18 → 2.0.20
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/api.ts +1 -0
- package/src/component.ts +3 -1
- package/src/terminal.ts +7 -35
- package/src/types.ts +23 -1
package/package.json
CHANGED
package/src/api.ts
CHANGED
package/src/component.ts
CHANGED
|
@@ -130,7 +130,9 @@ export class ExtendableComponentsAdapter<
|
|
|
130
130
|
actions: this.context.store.actions,
|
|
131
131
|
},
|
|
132
132
|
api: {
|
|
133
|
-
effects:
|
|
133
|
+
effects:
|
|
134
|
+
(console.log(this.context.api.effects),
|
|
135
|
+
this.context.api.effects),
|
|
134
136
|
actions: this.context.api.actions,
|
|
135
137
|
},
|
|
136
138
|
terminal: {
|
package/src/terminal.ts
CHANGED
|
@@ -1,42 +1,14 @@
|
|
|
1
|
-
import { Dictionary,
|
|
2
|
-
import {
|
|
3
|
-
combineLatest,
|
|
4
|
-
distinct,
|
|
5
|
-
map,
|
|
6
|
-
NextObserver,
|
|
7
|
-
switchMap,
|
|
8
|
-
UnaryFunction,
|
|
9
|
-
} from "rxjs";
|
|
1
|
+
import { Dictionary, thru } from "lodash";
|
|
2
|
+
import { combineLatest, distinct, map, switchMap, UnaryFunction } from "rxjs";
|
|
10
3
|
import { ApiAdapter, ApiEffect } from "./api";
|
|
11
4
|
import { ExtendableDictionary } from "./lib";
|
|
12
5
|
import { ComputedSignal, TapObservable } from "./observable";
|
|
13
6
|
import { concat, proxyReplaySubject } from "./operators";
|
|
14
7
|
import { asStoreEffects, StoreAdapter, StoreEffects } from "./store";
|
|
15
|
-
import { Action, Effect, TapEffect } from "./types";
|
|
8
|
+
import { Action, asTapEffects, Effect, TapEffect, TapEffects } from "./types";
|
|
16
9
|
|
|
17
10
|
export interface TerminalEffect<Args, Result> extends TapEffect<Args, Result> {}
|
|
18
11
|
|
|
19
|
-
type TerminalEffects<Effects extends Dictionary<TapEffect<any, any>>> = {
|
|
20
|
-
[K in keyof Effects]: ReturnType<
|
|
21
|
-
<
|
|
22
|
-
Args extends Effects[K] extends TapEffect<infer Args, infer _>
|
|
23
|
-
? Args
|
|
24
|
-
: never,
|
|
25
|
-
Result extends Effects[K] extends TapEffect<infer _, infer Result>
|
|
26
|
-
? Result
|
|
27
|
-
: never,
|
|
28
|
-
>() => TerminalEffect<Args, Result>
|
|
29
|
-
>;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const asTerminalEffects = <Effects extends Dictionary<TapEffect<any, any>>>(
|
|
33
|
-
effects: Effects,
|
|
34
|
-
observer?: NextObserver<TapObservable<any>>,
|
|
35
|
-
): TerminalEffects<Effects> =>
|
|
36
|
-
mapValues(effects, (effect) =>
|
|
37
|
-
memoize((args) => tap(effect(args), (value) => observer?.next(value))),
|
|
38
|
-
);
|
|
39
|
-
|
|
40
12
|
export class TerminalAdapter<
|
|
41
13
|
Effects extends Dictionary<TerminalEffect<any, any>>,
|
|
42
14
|
Actions extends Dictionary<Action<any, any>>,
|
|
@@ -84,10 +56,10 @@ export class ExtendableTerminalAdapter<
|
|
|
84
56
|
effects: StoreEffects<StoreSignals>;
|
|
85
57
|
};
|
|
86
58
|
api: {
|
|
87
|
-
effects:
|
|
59
|
+
effects: TapEffects<ApiEffects>;
|
|
88
60
|
};
|
|
89
61
|
terminal: {
|
|
90
|
-
effects:
|
|
62
|
+
effects: TapEffects<Effects>;
|
|
91
63
|
};
|
|
92
64
|
},
|
|
93
65
|
Effect<Args, Result>
|
|
@@ -121,10 +93,10 @@ export class ExtendableTerminalAdapter<
|
|
|
121
93
|
effects: asStoreEffects(this.context.store.signals, deps),
|
|
122
94
|
},
|
|
123
95
|
api: {
|
|
124
|
-
effects:
|
|
96
|
+
effects: asTapEffects(this.context.api.effects, deps),
|
|
125
97
|
},
|
|
126
98
|
terminal: {
|
|
127
|
-
effects:
|
|
99
|
+
effects: asTapEffects(currentEffects, deps),
|
|
128
100
|
},
|
|
129
101
|
}),
|
|
130
102
|
(effect) => (args) => new TapObservable(effect(args), deps),
|
package/src/types.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Dictionary, mapValues, memoize, tap } from "lodash";
|
|
1
2
|
import { UnaryFunction } from "rxjs";
|
|
2
3
|
import { Observable } from "rxjs/internal/Observable";
|
|
3
|
-
import { ObservableInput } from "rxjs/internal/types";
|
|
4
|
+
import { NextObserver, ObservableInput } from "rxjs/internal/types";
|
|
4
5
|
import { TapObservable } from "./observable";
|
|
5
6
|
|
|
6
7
|
export interface Effect<Args, Result> extends UnaryFunction<
|
|
@@ -13,6 +14,27 @@ export interface TapEffect<Args, Result> extends UnaryFunction<
|
|
|
13
14
|
TapObservable<Result>
|
|
14
15
|
> {}
|
|
15
16
|
|
|
17
|
+
export type TapEffects<Effects extends Dictionary<TapEffect<any, any>>> = {
|
|
18
|
+
[K in keyof Effects]: ReturnType<
|
|
19
|
+
<
|
|
20
|
+
Args extends Effects[K] extends TapEffect<infer Args, infer _>
|
|
21
|
+
? Args
|
|
22
|
+
: never,
|
|
23
|
+
Result extends Effects[K] extends TapEffect<infer _, infer Result>
|
|
24
|
+
? Result
|
|
25
|
+
: never,
|
|
26
|
+
>() => TapEffect<Args, Result>
|
|
27
|
+
>;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const asTapEffects = <Effects extends Dictionary<TapEffect<any, any>>>(
|
|
31
|
+
effects: Effects,
|
|
32
|
+
observer?: NextObserver<TapObservable<any>>,
|
|
33
|
+
): TapEffects<Effects> =>
|
|
34
|
+
mapValues(effects, (effect) =>
|
|
35
|
+
memoize((args) => tap(effect(args), (source) => observer?.next(source))),
|
|
36
|
+
);
|
|
37
|
+
|
|
16
38
|
export interface Action<Args, Result> extends UnaryFunction<
|
|
17
39
|
Args,
|
|
18
40
|
Promise<Result>
|