/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/core/src/render3/reactivity/asserts.ts
34 строки
1 KB
SkyZeroZx
docs: add section about `reactive contexts`
17 дек 2025, 03:35
17 дек 2025, 03:35
62ccd64
Код
Авторство
О чём код?
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import {getActiveConsumer} from '../../../primitives/signals'; import {RuntimeError, RuntimeErrorCode} from '../../errors'; /** * Asserts that the current stack frame is not within a reactive context. Useful * to disallow certain code from running inside a reactive context (see {@link /api/core/rxjs-interop/toSignal toSignal}) * * @param debugFn a reference to the function making the assertion (used for the error message). * @see [Asserts the reactive context](guide/signals#asserts-the-reactive-context) * * @publicApi */ export function assertNotInReactiveContext(debugFn: Function, extraContext?: string): void { // Taking a `Function` instead of a string name here prevents the un-minified name of the function // from being retained in the bundle regardless of minification. if (getActiveConsumer() !== null) { throw new RuntimeError( RuntimeErrorCode.ASSERTION_NOT_INSIDE_REACTIVE_CONTEXT, ngDevMode && `${debugFn.name}() cannot be called from within a reactive context.${ extraContext ? ` ${extraContext}` : '' }`, ); } }