@tstdl/base 0.90.73 → 0.90.74
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 +2 -2
- package/signals/index.d.ts +1 -0
- package/signals/index.js +1 -0
- package/signals/notifier.d.ts +4 -0
- package/signals/notifier.js +10 -0
- package/signals/operators/derive-async.d.ts +31 -0
- package/signals/operators/derive-async.js +29 -0
- package/signals/operators/index.d.ts +2 -1
- package/signals/operators/index.js +2 -1
- package/signals/operators/switchAll.d.ts +2 -0
- package/signals/operators/{switch-map.js → switchAll.js} +1 -1
- package/text/dynamic-text.model.js +2 -2
- package/signals/operators/switch-map.d.ts +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.90.
|
|
3
|
+
"version": "0.90.74",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
"koa": "^2.15",
|
|
148
148
|
"minio": "^8.0",
|
|
149
149
|
"mjml": "^4.15",
|
|
150
|
-
"mongodb": "^6.
|
|
150
|
+
"mongodb": "^6.6",
|
|
151
151
|
"nodemailer": "^6.9",
|
|
152
152
|
"playwright": "^1.43",
|
|
153
153
|
"preact": "^10.21",
|
package/signals/index.d.ts
CHANGED
package/signals/index.js
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { concatAll, exhaustAll, mergeAll, switchAll, type Observable } from 'rxjs';
|
|
2
|
+
import { type Signal, type ToSignalOptions } from '../api.js';
|
|
3
|
+
export type DeriveAsyncOptions = ToSignalOptions & {
|
|
4
|
+
behavior?: DeriveAsyncBehavior;
|
|
5
|
+
};
|
|
6
|
+
declare const operatorMap: {
|
|
7
|
+
merge: typeof mergeAll;
|
|
8
|
+
concat: typeof concatAll;
|
|
9
|
+
exhaust: typeof exhaustAll;
|
|
10
|
+
switch: typeof switchAll;
|
|
11
|
+
};
|
|
12
|
+
export type DeriveAsyncBehavior = keyof typeof operatorMap;
|
|
13
|
+
type DeriveAsyncSourceParameter<T> = () => (T | Promise<T> | Observable<T>);
|
|
14
|
+
export declare function deriveAsync<T>(source: DeriveAsyncSourceParameter<T>): Signal<T | undefined>;
|
|
15
|
+
export declare function deriveAsync<T>(source: DeriveAsyncSourceParameter<T>, options: DeriveAsyncOptions & {
|
|
16
|
+
initialValue?: undefined;
|
|
17
|
+
requireSync?: false;
|
|
18
|
+
}): Signal<T | undefined>;
|
|
19
|
+
export declare function deriveAsync<T>(source: DeriveAsyncSourceParameter<T>, options: DeriveAsyncOptions & {
|
|
20
|
+
initialValue?: null;
|
|
21
|
+
requireSync?: false;
|
|
22
|
+
}): Signal<T | null>;
|
|
23
|
+
export declare function deriveAsync<T>(source: DeriveAsyncSourceParameter<T>, options: DeriveAsyncOptions & {
|
|
24
|
+
initialValue?: undefined;
|
|
25
|
+
requireSync: true;
|
|
26
|
+
}): Signal<T>;
|
|
27
|
+
export declare function deriveAsync<T, const U extends T>(source: DeriveAsyncSourceParameter<T>, options: DeriveAsyncOptions & {
|
|
28
|
+
initialValue: U;
|
|
29
|
+
requireSync?: false;
|
|
30
|
+
}): Signal<T | U>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Subject, concatAll, exhaustAll, isObservable, mergeAll, of, switchAll, takeUntil } from 'rxjs';
|
|
2
|
+
import { registerFinalization } from '../../memory/finalization.js';
|
|
3
|
+
import { isPromise } from '../../utils/type-guards.js';
|
|
4
|
+
import { computed, toSignal, untracked } from '../api.js';
|
|
5
|
+
import { effect } from '../implementation/effect.js';
|
|
6
|
+
const operatorMap = {
|
|
7
|
+
merge: mergeAll,
|
|
8
|
+
concat: concatAll,
|
|
9
|
+
exhaust: exhaustAll,
|
|
10
|
+
switch: switchAll,
|
|
11
|
+
};
|
|
12
|
+
export function deriveAsync(source, options) {
|
|
13
|
+
const outerSource = computed(source);
|
|
14
|
+
const source$ = new Subject();
|
|
15
|
+
const destroy$ = new Subject();
|
|
16
|
+
const operator = operatorMap[options?.behavior ?? 'switch'];
|
|
17
|
+
const valueSource$ = source$.pipe(operator(), takeUntil(destroy$));
|
|
18
|
+
const result = toSignal(valueSource$, options);
|
|
19
|
+
const effectRef = effect(() => {
|
|
20
|
+
const rawSource = outerSource();
|
|
21
|
+
const observableInput = (isPromise(rawSource) || isObservable(rawSource)) ? rawSource : of(rawSource);
|
|
22
|
+
untracked(() => source$.next(observableInput));
|
|
23
|
+
});
|
|
24
|
+
registerFinalization(result, () => {
|
|
25
|
+
destroy$.next();
|
|
26
|
+
effectRef.destroy();
|
|
27
|
+
});
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isObservable } from 'rxjs';
|
|
2
2
|
import { inject } from '../injector/inject.js';
|
|
3
3
|
import { computed, isSignal, toObservable, toSignal, untracked } from '../signals/api.js';
|
|
4
|
-
import {
|
|
4
|
+
import { switchAll } from '../signals/index.js';
|
|
5
5
|
import { runInUntracked } from '../signals/untracked-operator.js';
|
|
6
6
|
import { isString } from '../utils/type-guards.js';
|
|
7
7
|
import { LocalizationService } from './localization.service.js';
|
|
@@ -12,7 +12,7 @@ export function resolveDynamicText(text, localizationService = inject(Localizati
|
|
|
12
12
|
: isObservable(text)
|
|
13
13
|
? untracked(() => toSignal(text.pipe(runInUntracked()), { initialValue: missingLocalizationKeyText }))
|
|
14
14
|
: computed(() => text);
|
|
15
|
-
return
|
|
15
|
+
return switchAll(() => {
|
|
16
16
|
const localizableText = localizableTextSignal();
|
|
17
17
|
return isString(localizableText) ? computed(() => localizableText) : localizationService.localize(localizableText);
|
|
18
18
|
});
|