-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchunk-7F6UZAKO.js
More file actions
140 lines (137 loc) · 4.36 KB
/
chunk-7F6UZAKO.js
File metadata and controls
140 lines (137 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import {
DestroyRef,
Injector,
Observable,
ReplaySubject,
RuntimeError,
__name,
assertInInjectionContext,
assertNotInReactiveContext,
computed,
effect,
getOutputDestroyRef,
inject,
signal,
takeUntil,
untracked
} from "./chunk-2CX5BJWG.js";
// node_modules/@angular/core/fesm2022/rxjs-interop.mjs
function takeUntilDestroyed(destroyRef) {
if (!destroyRef) {
ngDevMode && assertInInjectionContext(takeUntilDestroyed);
destroyRef = inject(DestroyRef);
}
const destroyed$ = new Observable((subscriber) => {
if (destroyRef.destroyed) {
subscriber.next();
return;
}
const unregisterFn = destroyRef.onDestroy(subscriber.next.bind(subscriber));
return unregisterFn;
});
return (source) => {
return source.pipe(takeUntil(destroyed$));
};
}
__name(takeUntilDestroyed, "takeUntilDestroyed");
function outputToObservable(ref) {
const destroyRef = getOutputDestroyRef(ref);
return new Observable((observer) => {
const unregisterOnDestroy = destroyRef?.onDestroy(() => observer.complete());
const subscription = ref.subscribe((v) => observer.next(v));
return () => {
subscription.unsubscribe();
unregisterOnDestroy?.();
};
});
}
__name(outputToObservable, "outputToObservable");
function toObservable(source, options) {
if (ngDevMode && !options?.injector) {
assertInInjectionContext(toObservable);
}
const injector = options?.injector ?? inject(Injector);
const subject = new ReplaySubject(1);
const watcher = effect(() => {
let value;
try {
value = source();
} catch (err) {
untracked(() => subject.error(err));
return;
}
untracked(() => subject.next(value));
}, { injector, manualCleanup: true });
injector.get(DestroyRef).onDestroy(() => {
watcher.destroy();
subject.complete();
});
return subject.asObservable();
}
__name(toObservable, "toObservable");
function toSignal(source, options) {
typeof ngDevMode !== "undefined" && ngDevMode && assertNotInReactiveContext(toSignal, "Invoking `toSignal` causes new subscriptions every time. Consider moving `toSignal` outside of the reactive context and read the signal value where needed.");
const requiresCleanup = !options?.manualCleanup;
if (ngDevMode && requiresCleanup && !options?.injector) {
assertInInjectionContext(toSignal);
}
const cleanupRef = requiresCleanup ? options?.injector?.get(DestroyRef) ?? inject(DestroyRef) : null;
const equal = makeToSignalEqual(options?.equal);
let state;
if (options?.requireSync) {
state = signal({
kind: 0
/* StateKind.NoValue */
}, { equal });
} else {
state = signal({ kind: 1, value: options?.initialValue }, { equal });
}
let destroyUnregisterFn;
const sub = source.subscribe({
next: /* @__PURE__ */ __name((value) => state.set({ kind: 1, value }), "next"),
error: /* @__PURE__ */ __name((error) => {
state.set({ kind: 2, error });
destroyUnregisterFn?.();
}, "error"),
complete: /* @__PURE__ */ __name(() => {
destroyUnregisterFn?.();
}, "complete")
// Completion of the Observable is meaningless to the signal. Signals don't have a concept of
// "complete".
});
if (options?.requireSync && state().kind === 0) {
throw new RuntimeError(601, (typeof ngDevMode === "undefined" || ngDevMode) && "`toSignal()` called with `requireSync` but `Observable` did not emit synchronously.");
}
destroyUnregisterFn = cleanupRef?.onDestroy(sub.unsubscribe.bind(sub));
return computed(() => {
const current = state();
switch (current.kind) {
case 1:
return current.value;
case 2:
throw current.error;
case 0:
throw new RuntimeError(601, (typeof ngDevMode === "undefined" || ngDevMode) && "`toSignal()` called with `requireSync` but `Observable` did not emit synchronously.");
}
}, { equal: options?.equal });
}
__name(toSignal, "toSignal");
function makeToSignalEqual(userEquality = Object.is) {
return (a, b) => a.kind === 1 && b.kind === 1 && userEquality(a.value, b.value);
}
__name(makeToSignalEqual, "makeToSignalEqual");
export {
takeUntilDestroyed,
outputToObservable,
toObservable,
toSignal
};
/*! Bundled license information:
@angular/core/fesm2022/rxjs-interop.mjs:
(**
* @license Angular v0.0.0
* (c) 2010-2025 Google LLC. https://angular.io/
* License: MIT
*)
*/
//# sourceMappingURL=chunk-7F6UZAKO.js.map