UNPKG

@ynmstudio/utils

Version:
19 lines (15 loc) 728 B
import { computed } from '@angular/core'; import { toSignal } from '@angular/core/rxjs-interop'; import { of } from 'rxjs'; import { map, catchError } from 'rxjs/operators'; function toSignalWithError(obs$) { const source = toSignal(obs$.pipe(map((value) => ({ value, error: undefined })), catchError((err) => of({ value: undefined, error: err })))); const value = computed(() => source()?.value, ...(ngDevMode ? [{ debugName: "value" }] : [])); const error = computed(() => source()?.error, ...(ngDevMode ? [{ debugName: "error" }] : [])); return { value, error }; } /** * Generated bundle index. Do not edit. */ export { toSignalWithError }; //# sourceMappingURL=ynmstudio-utils-signal-with-error.mjs.map