diff --git a/packages/core/src/render3/reactivity/untracked.ts b/packages/core/src/render3/reactivity/untracked.ts index defa070ce14..1605c535a04 100644 --- a/packages/core/src/render3/reactivity/untracked.ts +++ b/packages/core/src/render3/reactivity/untracked.ts @@ -6,19 +6,12 @@ * found in the LICENSE file at https://angular.dev/license */ -import {setActiveConsumer} from '@angular/core/primitives/signals'; +import {untracked as untrackedPrimitive} from '@angular/core/primitives/signals'; /** * Execute an arbitrary function in a non-reactive (non-tracking) context. The executed function * can, optionally, return a value. */ export function untracked(nonReactiveReadsFn: () => T): T { - const prevConsumer = setActiveConsumer(null); - // We are not trying to catch any particular errors here, just making sure that the consumers - // stack is restored in case of errors. - try { - return nonReactiveReadsFn(); - } finally { - setActiveConsumer(prevConsumer); - } + return untrackedPrimitive(nonReactiveReadsFn); }