@signaltree/core 9.2.2 → 9.5.0
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/README.md +42 -27
- package/dist/Action.js +15 -0
- package/dist/AsyncAction.js +91 -0
- package/dist/AsyncScheduler.js +37 -0
- package/dist/ObjectUnsubscribedError.js +11 -0
- package/dist/Observable.js +103 -0
- package/dist/OperatorSubscriber.js +62 -0
- package/dist/Scheduler.js +17 -0
- package/dist/Subject.js +162 -0
- package/dist/Subscriber.js +153 -0
- package/dist/Subscription.js +144 -0
- package/dist/UnsubscriptionError.js +14 -0
- package/dist/args.js +10 -0
- package/dist/arrRemove.js +8 -0
- package/dist/async.js +6 -0
- package/dist/config.js +4 -0
- package/dist/createErrorClass.js +12 -0
- package/dist/dateTimestampProvider.js +6 -0
- package/dist/debounceTime.js +46 -0
- package/dist/distinctUntilChanged.js +25 -0
- package/dist/enhancers/devtools/devtools.js +11 -5
- package/dist/enhancers/time-travel/time-travel.js +11 -5
- package/dist/errorContext.js +7 -0
- package/dist/executeSchedule.js +19 -0
- package/dist/filter.js +11 -0
- package/dist/from.js +8 -0
- package/dist/identity.js +5 -0
- package/dist/index.js +4 -0
- package/dist/innerFrom.js +145 -0
- package/dist/intervalProvider.js +17 -0
- package/dist/isArrayLike.js +3 -0
- package/dist/isAsyncIterable.js +7 -0
- package/dist/isFunction.js +5 -0
- package/dist/isInteropObservable.js +8 -0
- package/dist/isIterable.js +8 -0
- package/dist/isObservable.js +8 -0
- package/dist/isPromise.js +7 -0
- package/dist/isReadableStreamLike.js +40 -0
- package/dist/isScheduler.js +7 -0
- package/dist/iterator.js +9 -0
- package/dist/lib/internals/intercept-leaf-signals.js +4 -2
- package/dist/lib/markers/async-query.js +134 -0
- package/dist/lib/markers/async-source.js +122 -0
- package/dist/lib/rxjs-interop/rx-method.js +50 -0
- package/dist/lib/write-context.js +15 -0
- package/dist/lift.js +22 -0
- package/dist/noop.js +3 -0
- package/dist/observable2.js +3 -0
- package/dist/observeOn.js +12 -0
- package/dist/of.js +13 -0
- package/dist/pipe.js +15 -0
- package/dist/reportUnhandledError.js +11 -0
- package/dist/rxjs-interop.js +1 -0
- package/dist/scheduleArray.js +20 -0
- package/dist/scheduleAsyncIterable.js +25 -0
- package/dist/scheduleIterable.js +34 -0
- package/dist/scheduleObservable.js +9 -0
- package/dist/schedulePromise.js +9 -0
- package/dist/scheduleReadableStreamLike.js +8 -0
- package/dist/scheduled.js +39 -0
- package/dist/subscribeOn.js +10 -0
- package/dist/switchMap.js +26 -0
- package/dist/tap.js +42 -0
- package/dist/throwUnobservableError.js +5 -0
- package/dist/timeoutProvider.js +17 -0
- package/package.json +6 -1
- package/src/index.d.ts +5 -1
- package/src/lib/internals/intercept-leaf-signals.d.ts +4 -1
- package/src/lib/markers/async-query.d.ts +31 -0
- package/src/lib/markers/async-source.d.ts +27 -0
- package/src/lib/markers/index.d.ts +2 -0
- package/src/lib/rxjs-interop/index.d.ts +1 -0
- package/src/lib/rxjs-interop/rx-method.d.ts +11 -0
- package/src/lib/types.d.ts +8 -0
- package/src/lib/write-context.d.ts +3 -0
- package/src/rxjs-interop.d.ts +1 -0
package/dist/of.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { popScheduler } from './args.js';
|
|
2
|
+
import { from } from './from.js';
|
|
3
|
+
|
|
4
|
+
function of() {
|
|
5
|
+
var args = [];
|
|
6
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
7
|
+
args[_i] = arguments[_i];
|
|
8
|
+
}
|
|
9
|
+
var scheduler = popScheduler(args);
|
|
10
|
+
return from(args, scheduler);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { of };
|
package/dist/pipe.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { identity } from './identity.js';
|
|
2
|
+
|
|
3
|
+
function pipeFromArray(fns) {
|
|
4
|
+
if (fns.length === 0) {
|
|
5
|
+
return identity;
|
|
6
|
+
}
|
|
7
|
+
if (fns.length === 1) {
|
|
8
|
+
return fns[0];
|
|
9
|
+
}
|
|
10
|
+
return function piped(input) {
|
|
11
|
+
return fns.reduce(function (prev, fn) { return fn(prev); }, input);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { pipeFromArray };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { rxMethod } from './lib/rxjs-interop/rx-method.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Observable } from './Observable.js';
|
|
2
|
+
|
|
3
|
+
function scheduleArray(input, scheduler) {
|
|
4
|
+
return new Observable(function (subscriber) {
|
|
5
|
+
var i = 0;
|
|
6
|
+
return scheduler.schedule(function () {
|
|
7
|
+
if (i === input.length) {
|
|
8
|
+
subscriber.complete();
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
subscriber.next(input[i++]);
|
|
12
|
+
if (!subscriber.closed) {
|
|
13
|
+
this.schedule();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { scheduleArray };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Observable } from './Observable.js';
|
|
2
|
+
import { executeSchedule } from './executeSchedule.js';
|
|
3
|
+
|
|
4
|
+
function scheduleAsyncIterable(input, scheduler) {
|
|
5
|
+
if (!input) {
|
|
6
|
+
throw new Error('Iterable cannot be null');
|
|
7
|
+
}
|
|
8
|
+
return new Observable(function (subscriber) {
|
|
9
|
+
executeSchedule(subscriber, scheduler, function () {
|
|
10
|
+
var iterator = input[Symbol.asyncIterator]();
|
|
11
|
+
executeSchedule(subscriber, scheduler, function () {
|
|
12
|
+
iterator.next().then(function (result) {
|
|
13
|
+
if (result.done) {
|
|
14
|
+
subscriber.complete();
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
subscriber.next(result.value);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}, 0, true);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { scheduleAsyncIterable };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Observable } from './Observable.js';
|
|
2
|
+
import { iterator } from './iterator.js';
|
|
3
|
+
import { isFunction } from './isFunction.js';
|
|
4
|
+
import { executeSchedule } from './executeSchedule.js';
|
|
5
|
+
|
|
6
|
+
function scheduleIterable(input, scheduler) {
|
|
7
|
+
return new Observable(function (subscriber) {
|
|
8
|
+
var iterator$1;
|
|
9
|
+
executeSchedule(subscriber, scheduler, function () {
|
|
10
|
+
iterator$1 = input[iterator]();
|
|
11
|
+
executeSchedule(subscriber, scheduler, function () {
|
|
12
|
+
var _a;
|
|
13
|
+
var value;
|
|
14
|
+
var done;
|
|
15
|
+
try {
|
|
16
|
+
(_a = iterator$1.next(), value = _a.value, done = _a.done);
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
subscriber.error(err);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (done) {
|
|
23
|
+
subscriber.complete();
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
subscriber.next(value);
|
|
27
|
+
}
|
|
28
|
+
}, 0, true);
|
|
29
|
+
});
|
|
30
|
+
return function () { return isFunction(iterator$1 === null || iterator$1 === void 0 ? void 0 : iterator$1.return) && iterator$1.return(); };
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { scheduleIterable };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { innerFrom } from './innerFrom.js';
|
|
2
|
+
import { observeOn } from './observeOn.js';
|
|
3
|
+
import { subscribeOn } from './subscribeOn.js';
|
|
4
|
+
|
|
5
|
+
function scheduleObservable(input, scheduler) {
|
|
6
|
+
return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { scheduleObservable };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { innerFrom } from './innerFrom.js';
|
|
2
|
+
import { observeOn } from './observeOn.js';
|
|
3
|
+
import { subscribeOn } from './subscribeOn.js';
|
|
4
|
+
|
|
5
|
+
function schedulePromise(input, scheduler) {
|
|
6
|
+
return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { schedulePromise };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { scheduleAsyncIterable } from './scheduleAsyncIterable.js';
|
|
2
|
+
import { readableStreamLikeToAsyncGenerator } from './isReadableStreamLike.js';
|
|
3
|
+
|
|
4
|
+
function scheduleReadableStreamLike(input, scheduler) {
|
|
5
|
+
return scheduleAsyncIterable(readableStreamLikeToAsyncGenerator(input), scheduler);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { scheduleReadableStreamLike };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { scheduleObservable } from './scheduleObservable.js';
|
|
2
|
+
import { schedulePromise } from './schedulePromise.js';
|
|
3
|
+
import { scheduleArray } from './scheduleArray.js';
|
|
4
|
+
import { scheduleIterable } from './scheduleIterable.js';
|
|
5
|
+
import { scheduleAsyncIterable } from './scheduleAsyncIterable.js';
|
|
6
|
+
import { isInteropObservable } from './isInteropObservable.js';
|
|
7
|
+
import { isPromise } from './isPromise.js';
|
|
8
|
+
import { isArrayLike } from './isArrayLike.js';
|
|
9
|
+
import { isIterable } from './isIterable.js';
|
|
10
|
+
import { isAsyncIterable } from './isAsyncIterable.js';
|
|
11
|
+
import { createInvalidObservableTypeError } from './throwUnobservableError.js';
|
|
12
|
+
import { isReadableStreamLike } from './isReadableStreamLike.js';
|
|
13
|
+
import { scheduleReadableStreamLike } from './scheduleReadableStreamLike.js';
|
|
14
|
+
|
|
15
|
+
function scheduled(input, scheduler) {
|
|
16
|
+
if (input != null) {
|
|
17
|
+
if (isInteropObservable(input)) {
|
|
18
|
+
return scheduleObservable(input, scheduler);
|
|
19
|
+
}
|
|
20
|
+
if (isArrayLike(input)) {
|
|
21
|
+
return scheduleArray(input, scheduler);
|
|
22
|
+
}
|
|
23
|
+
if (isPromise(input)) {
|
|
24
|
+
return schedulePromise(input, scheduler);
|
|
25
|
+
}
|
|
26
|
+
if (isAsyncIterable(input)) {
|
|
27
|
+
return scheduleAsyncIterable(input, scheduler);
|
|
28
|
+
}
|
|
29
|
+
if (isIterable(input)) {
|
|
30
|
+
return scheduleIterable(input, scheduler);
|
|
31
|
+
}
|
|
32
|
+
if (isReadableStreamLike(input)) {
|
|
33
|
+
return scheduleReadableStreamLike(input, scheduler);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
throw createInvalidObservableTypeError(input);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { scheduled };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { operate } from './lift.js';
|
|
2
|
+
|
|
3
|
+
function subscribeOn(scheduler, delay) {
|
|
4
|
+
if (delay === void 0) { delay = 0; }
|
|
5
|
+
return operate(function (source, subscriber) {
|
|
6
|
+
subscriber.add(scheduler.schedule(function () { return source.subscribe(subscriber); }, delay));
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { subscribeOn };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { innerFrom } from './innerFrom.js';
|
|
2
|
+
import { operate } from './lift.js';
|
|
3
|
+
import { createOperatorSubscriber } from './OperatorSubscriber.js';
|
|
4
|
+
|
|
5
|
+
function switchMap(project, resultSelector) {
|
|
6
|
+
return operate(function (source, subscriber) {
|
|
7
|
+
var innerSubscriber = null;
|
|
8
|
+
var index = 0;
|
|
9
|
+
var isComplete = false;
|
|
10
|
+
var checkComplete = function () { return isComplete && !innerSubscriber && subscriber.complete(); };
|
|
11
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
12
|
+
innerSubscriber === null || innerSubscriber === void 0 ? void 0 : innerSubscriber.unsubscribe();
|
|
13
|
+
var innerIndex = 0;
|
|
14
|
+
var outerIndex = index++;
|
|
15
|
+
innerFrom(project(value, outerIndex)).subscribe((innerSubscriber = createOperatorSubscriber(subscriber, function (innerValue) { return subscriber.next(resultSelector ? resultSelector(value, innerValue, outerIndex, innerIndex++) : innerValue); }, function () {
|
|
16
|
+
innerSubscriber = null;
|
|
17
|
+
checkComplete();
|
|
18
|
+
})));
|
|
19
|
+
}, function () {
|
|
20
|
+
isComplete = true;
|
|
21
|
+
checkComplete();
|
|
22
|
+
}));
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { switchMap };
|
package/dist/tap.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { isFunction } from './isFunction.js';
|
|
2
|
+
import { operate } from './lift.js';
|
|
3
|
+
import { createOperatorSubscriber } from './OperatorSubscriber.js';
|
|
4
|
+
import { identity } from './identity.js';
|
|
5
|
+
|
|
6
|
+
function tap(observerOrNext, error, complete) {
|
|
7
|
+
var tapObserver = isFunction(observerOrNext) || error || complete
|
|
8
|
+
?
|
|
9
|
+
{ next: observerOrNext, error: error, complete: complete }
|
|
10
|
+
: observerOrNext;
|
|
11
|
+
return tapObserver
|
|
12
|
+
? operate(function (source, subscriber) {
|
|
13
|
+
var _a;
|
|
14
|
+
(_a = tapObserver.subscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
|
|
15
|
+
var isUnsub = true;
|
|
16
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
17
|
+
var _a;
|
|
18
|
+
(_a = tapObserver.next) === null || _a === void 0 ? void 0 : _a.call(tapObserver, value);
|
|
19
|
+
subscriber.next(value);
|
|
20
|
+
}, function () {
|
|
21
|
+
var _a;
|
|
22
|
+
isUnsub = false;
|
|
23
|
+
(_a = tapObserver.complete) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
|
|
24
|
+
subscriber.complete();
|
|
25
|
+
}, function (err) {
|
|
26
|
+
var _a;
|
|
27
|
+
isUnsub = false;
|
|
28
|
+
(_a = tapObserver.error) === null || _a === void 0 ? void 0 : _a.call(tapObserver, err);
|
|
29
|
+
subscriber.error(err);
|
|
30
|
+
}, function () {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
if (isUnsub) {
|
|
33
|
+
(_a = tapObserver.unsubscribe) === null || _a === void 0 ? void 0 : _a.call(tapObserver);
|
|
34
|
+
}
|
|
35
|
+
(_b = tapObserver.finalize) === null || _b === void 0 ? void 0 : _b.call(tapObserver);
|
|
36
|
+
}));
|
|
37
|
+
})
|
|
38
|
+
:
|
|
39
|
+
identity;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { tap };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
function createInvalidObservableTypeError(input) {
|
|
2
|
+
return new TypeError("You provided " + (input !== null && typeof input === 'object' ? 'an invalid object' : "'" + input + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.");
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export { createInvalidObservableTypeError };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { __spreadArray, __read } from 'tslib';
|
|
2
|
+
|
|
3
|
+
var timeoutProvider = {
|
|
4
|
+
setTimeout: function (handler, timeout) {
|
|
5
|
+
var args = [];
|
|
6
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
7
|
+
args[_i - 2] = arguments[_i];
|
|
8
|
+
}
|
|
9
|
+
return setTimeout.apply(void 0, __spreadArray([handler, timeout], __read(args)));
|
|
10
|
+
},
|
|
11
|
+
clearTimeout: function (handle) {
|
|
12
|
+
return (clearTimeout)(handle);
|
|
13
|
+
},
|
|
14
|
+
delegate: undefined,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { timeoutProvider };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signaltree/core",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.5.0",
|
|
4
4
|
"description": "Reactive JSON for Angular. JSON branches, reactive leaves. No actions. No reducers. No selectors.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -29,6 +29,11 @@
|
|
|
29
29
|
"import": "./dist/storage.js",
|
|
30
30
|
"default": "./dist/storage.js"
|
|
31
31
|
},
|
|
32
|
+
"./rxjs-interop": {
|
|
33
|
+
"types": "./src/rxjs-interop.d.ts",
|
|
34
|
+
"import": "./dist/rxjs-interop.js",
|
|
35
|
+
"default": "./dist/rxjs-interop.js"
|
|
36
|
+
},
|
|
32
37
|
"./package.json": "./package.json"
|
|
33
38
|
},
|
|
34
39
|
"peerDependencies": {
|
package/src/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { signalTree } from './lib/signal-tree';
|
|
2
|
-
export type { ISignalTree, SignalTree, SignalTreeBase, TreeNode, CallableWritableSignal, AccessibleNode, NodeAccessor, Primitive, NotFn, TreeConfig, Enhancer, EnhancerMeta, EnhancerWithMeta, EntitySignal, EntityMapMarker, EntityConfig, MutationOptions, AddOptions, AddManyOptions, TimeTravelEntry, TimeTravelMethods, EnhancerCleanup, EffectsMethods, } from './lib/types';
|
|
2
|
+
export type { ISignalTree, SignalTree, SignalTreeBase, TreeNode, CallableWritableSignal, AccessibleNode, NodeAccessor, Primitive, NotFn, TreeConfig, Enhancer, EnhancerMeta, EnhancerWithMeta, EntitySignal, EntityMapMarker, EntityConfig, MutationOptions, AddOptions, AddManyOptions, TimeTravelEntry, TimeTravelMethods, EnhancerCleanup, EffectsMethods, UpdateMetadata, } from './lib/types';
|
|
3
|
+
export { withWriteContext, getActiveWriteContext } from './lib/write-context';
|
|
4
|
+
export { interceptLeafSignals } from './lib/internals/intercept-leaf-signals';
|
|
3
5
|
export { entityMap } from './lib/types';
|
|
4
6
|
export type { ProcessDerived, DeepMergeTree, DerivedFactory, WithDerived, } from './lib/internals/derived-types';
|
|
5
7
|
export { derivedFrom, externalDerived } from './lib/internals/derived-types';
|
|
@@ -8,6 +10,8 @@ export { isDerivedMarker, type DerivedMarker, type DerivedType, } from './lib/ma
|
|
|
8
10
|
export { status, isStatusMarker, LoadingState, type StatusMarker, type StatusSignal, type StatusConfig, } from './lib/markers/status';
|
|
9
11
|
export { stored, isStoredMarker, createStorageKeys, clearStoragePrefix, type StoredMarker, type StoredSignal, type StoredOptions, } from './lib/markers/stored';
|
|
10
12
|
export { form, isFormMarker, createFormSignal, validators, FORM_MARKER, type FormMarker, type FormSignal, type FormConfig, type FormFields, type FormWizard, type WizardConfig, type WizardStepConfig, type Validator, type AsyncValidator, } from './lib/markers/form';
|
|
13
|
+
export { asyncSource, isAsyncSourceMarker, createAsyncSourceSignal, ASYNC_SOURCE_MARKER, type AsyncSourceMarker, type AsyncSourceSignal, type AsyncSourceConfig, type AsyncSourceLoader, } from './lib/markers/async-source';
|
|
14
|
+
export { asyncQuery, isAsyncQueryMarker, createAsyncQuerySignal, ASYNC_QUERY_MARKER, type AsyncQueryMarker, type AsyncQuerySignal, type AsyncQueryConfig, type AsyncQueryFn, } from './lib/markers/async-query';
|
|
11
15
|
export { registerMarkerProcessor } from './lib/internals/materialize-markers';
|
|
12
16
|
export { equal, deepEqual, isNodeAccessor, isAnySignal, toWritableSignal, parsePath, composeEnhancers, isBuiltInObject, } from './lib/utils';
|
|
13
17
|
export { getPathNotifier } from './lib/path-notifier';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Signal, type WritableSignal } from '@angular/core';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
export declare const ASYNC_QUERY_MARKER: unique symbol;
|
|
4
|
+
export type AsyncQueryFn<TInput, TResult> = (input: TInput) => Observable<TResult> | Promise<TResult>;
|
|
5
|
+
export interface AsyncQueryConfig<TInput, TResult> {
|
|
6
|
+
initialInput?: TInput;
|
|
7
|
+
initialResult?: TResult;
|
|
8
|
+
query: AsyncQueryFn<TInput, TResult>;
|
|
9
|
+
debounce?: number;
|
|
10
|
+
filter?: (input: TInput) => boolean;
|
|
11
|
+
equal?: (a: TInput, b: TInput) => boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface AsyncQueryMarker<TInput, TResult> {
|
|
14
|
+
[ASYNC_QUERY_MARKER]: true;
|
|
15
|
+
config: AsyncQueryConfig<TInput, TResult>;
|
|
16
|
+
readonly __inputType?: TInput;
|
|
17
|
+
readonly __resultType?: TResult;
|
|
18
|
+
}
|
|
19
|
+
export interface AsyncQuerySignal<TInput, TResult> {
|
|
20
|
+
(): TResult | undefined;
|
|
21
|
+
readonly input: WritableSignal<TInput | undefined>;
|
|
22
|
+
readonly results: Signal<TResult | undefined>;
|
|
23
|
+
readonly data: Signal<TResult | undefined>;
|
|
24
|
+
readonly loading: Signal<boolean>;
|
|
25
|
+
readonly error: Signal<unknown | null>;
|
|
26
|
+
rerun(): void;
|
|
27
|
+
reset(): void;
|
|
28
|
+
}
|
|
29
|
+
export declare function asyncQuery<TInput, TResult>(config: AsyncQueryConfig<TInput, TResult>): AsyncQueryMarker<TInput, TResult>;
|
|
30
|
+
export declare function isAsyncQueryMarker(value: unknown): value is AsyncQueryMarker<unknown, unknown>;
|
|
31
|
+
export declare function createAsyncQuerySignal<TInput, TResult>(marker: AsyncQueryMarker<TInput, TResult>): AsyncQuerySignal<TInput, TResult>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Signal } from '@angular/core';
|
|
2
|
+
import { type Observable } from 'rxjs';
|
|
3
|
+
export declare const ASYNC_SOURCE_MARKER: unique symbol;
|
|
4
|
+
export type AsyncSourceLoader<T> = () => Observable<T> | Promise<T>;
|
|
5
|
+
export interface AsyncSourceConfig<T> {
|
|
6
|
+
initial?: T;
|
|
7
|
+
load: AsyncSourceLoader<T>;
|
|
8
|
+
lazy?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface AsyncSourceMarker<T> {
|
|
11
|
+
[ASYNC_SOURCE_MARKER]: true;
|
|
12
|
+
config: AsyncSourceConfig<T>;
|
|
13
|
+
readonly __valueType?: T;
|
|
14
|
+
}
|
|
15
|
+
export interface AsyncSourceSignal<T> {
|
|
16
|
+
(): T | undefined;
|
|
17
|
+
readonly data: Signal<T | undefined>;
|
|
18
|
+
readonly loading: Signal<boolean>;
|
|
19
|
+
readonly error: Signal<unknown | null>;
|
|
20
|
+
refresh(): void;
|
|
21
|
+
set(value: T): void;
|
|
22
|
+
update(updater: (current: T | undefined) => T): void;
|
|
23
|
+
reset(): void;
|
|
24
|
+
}
|
|
25
|
+
export declare function asyncSource<T>(config: AsyncSourceConfig<T>): AsyncSourceMarker<T>;
|
|
26
|
+
export declare function isAsyncSourceMarker(value: unknown): value is AsyncSourceMarker<unknown>;
|
|
27
|
+
export declare function createAsyncSourceSignal<T>(marker: AsyncSourceMarker<T>): AsyncSourceSignal<T>;
|
|
@@ -2,3 +2,5 @@ export { isDerivedMarker, getDerivedMarkerSymbol, type DerivedMarker, type Deriv
|
|
|
2
2
|
export { status, isStatusMarker, createStatusSignal, LoadingState, STATUS_MARKER, type StatusMarker, type StatusSignal, type StatusConfig, } from './status';
|
|
3
3
|
export { stored, isStoredMarker, createStoredSignal, createStorageKeys, clearStoragePrefix, STORED_MARKER, type StoredMarker, type StoredSignal, type StoredOptions, type MigrationFn, } from './stored';
|
|
4
4
|
export { form, isFormMarker, createFormSignal, validators, FORM_MARKER, type FormMarker, type FormSignal, type FormConfig, type FormFields, type FormWizard, type WizardConfig, type WizardStepConfig, type Validator, type AsyncValidator, } from './form';
|
|
5
|
+
export { asyncSource, isAsyncSourceMarker, createAsyncSourceSignal, ASYNC_SOURCE_MARKER, type AsyncSourceMarker, type AsyncSourceSignal, type AsyncSourceConfig, type AsyncSourceLoader, } from './async-source';
|
|
6
|
+
export { asyncQuery, isAsyncQueryMarker, createAsyncQuerySignal, ASYNC_QUERY_MARKER, type AsyncQueryMarker, type AsyncQuerySignal, type AsyncQueryConfig, type AsyncQueryFn, } from './async-query';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { rxMethod, type RxMethod, type RxMethodInput, } from './rx-method';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DestroyRef, Injector, type Signal } from '@angular/core';
|
|
2
|
+
import { type Observable, Subscription } from 'rxjs';
|
|
3
|
+
export type RxMethodInput<T> = T | Signal<T> | Observable<T>;
|
|
4
|
+
export interface RxMethod<T> {
|
|
5
|
+
(...args: [T] extends [void] ? [] | [RxMethodInput<T>] : [RxMethodInput<T>]): Subscription;
|
|
6
|
+
destroy(): void;
|
|
7
|
+
}
|
|
8
|
+
export declare function rxMethod<T = void>(generator: (source$: Observable<T>) => Observable<unknown>, options?: {
|
|
9
|
+
destroyRef?: DestroyRef;
|
|
10
|
+
injector?: Injector;
|
|
11
|
+
}): RxMethod<T>;
|
package/src/lib/types.d.ts
CHANGED
|
@@ -3,6 +3,14 @@ import { FormMarker, FormSignal } from './markers/form';
|
|
|
3
3
|
import { StatusMarker, StatusSignal } from './markers/status';
|
|
4
4
|
import { StoredMarker, StoredSignal } from './markers/stored';
|
|
5
5
|
import { SecurityValidatorConfig } from './security/security-validator';
|
|
6
|
+
export interface UpdateMetadata {
|
|
7
|
+
intent?: 'hydrate' | 'reset' | 'bulk' | 'migration' | 'user' | 'system';
|
|
8
|
+
source?: 'serialization' | 'time-travel' | 'devtools' | 'user' | 'system';
|
|
9
|
+
suppressGuardrails?: boolean;
|
|
10
|
+
correlationId?: string;
|
|
11
|
+
timestamp?: number;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
6
14
|
export interface TimeTravelConfig {
|
|
7
15
|
enabled?: boolean;
|
|
8
16
|
maxHistorySize?: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { rxMethod, type RxMethod, type RxMethodInput, } from './lib/rxjs-interop';
|