angular/packages/core/src/util
Alex Rickabaugh ffad7b8ea9 fix(core): untrack various core operations (#54614)
One downside of implicit dependency tracking in `effect()`s is that it's easy
to for downstream code to end up running inside the effect context by accident.
For example, if an effect raises an event (e.g. by `next()`ing a `Subject`), the
subscribers to that `Observable` will run inside the effect's reactive context,
and any signals read within the subscriber will end up as dependencies of the
effect. This is why the `untracked` function is useful, to run certain
operations without incidental signal reads ending up tracked.

However, knowing when this is necessary is non-trivial. For example, injecting
a dependency might cause it to be instantiated, which would run the constructor
in the effect context unless the injection operation is untracked.

Therefore, Angular will automatically drop the reactive context within a number
of framework APIs. This commit addresses these use cases:

* creating and destroying views
* creating and destroying DI injectors
* injecting dependencies
* emitting outputs

Fixes #54548

There are likely other APIs which would benefit from this approach, but this
is a start.

PR Close #54614
2024-02-29 11:38:54 +01:00
..
security refactor(core): Use intersections on branded types. (#49702) 2023-08-31 20:22:12 +00:00
array_utils.ts refactor(core): simplify array flatten logic (#48358) 2022-12-06 12:48:41 -08:00
assert.ts fix(core): untrack various core operations (#54614) 2024-02-29 11:38:54 +01:00
BUILD.bazel fix(core): untrack various core operations (#54614) 2024-02-29 11:38:54 +01:00
char_code.ts refactor(core): remove unused i18n placeholder for projection (#39172) 2020-10-27 10:39:37 -07:00
closure.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
coercion.ts docs: fix warning about an unknown decorator (#51237) 2023-08-01 13:00:53 -07:00
comparison.ts refactor(core): remove looseIdentical in favor of built-in Object.is (#37191) 2020-06-01 17:19:17 -04:00
decorators.ts feat(core): support usage of non-experimental decorators with TypeScript 5.0 (#49492) 2023-04-05 09:59:07 -07:00
dom.ts fix(core): correct incomplete escaping (#51557) 2023-08-29 19:48:25 +00:00
empty.ts refactor(core): type EMPTY_OBJ as never for improved type safety (#53571) 2024-01-04 12:07:13 -08:00
errors.ts refactor(core): remove unused error handler logic (#46216) 2022-06-02 13:40:16 -07:00
global.ts refactor(core): use globalThis for global (#50063) 2023-07-14 18:32:01 +00:00
is_dev_mode.ts fix(core): correctly check for typeof of undefined in ngDevMode check (#47480) 2022-09-23 14:00:46 -07:00
iterable.ts refactor(core): Drop Symbol.iterator shim (#49207) 2023-02-28 10:05:41 -08:00
lang.ts refactor(core): Remove isObservable() in favor isSubscribable(). (#49295) 2023-03-08 17:58:19 +00:00
ng_dev_mode.ts refactor(core): Allow mutation instead of reassignment of ngDevMode (#53862) 2024-01-24 18:38:50 -05:00
ng_i18n_closure_mode.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
ng_jit_mode.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
ng_reflect.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
noop.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
performance.ts fix(core): update feature usage marker (#53542) 2023-12-13 09:24:09 -08:00
property.ts feat(core): add ability to transform input values (#50420) 2023-05-30 13:01:13 -07:00
raf.ts fix(core): use setTimeout when coalescing tasks in Node.js (#50820) 2023-06-30 11:32:38 -07:00
stringify.ts refactor(docs): fix typo (#54247) 2024-02-05 15:05:36 +00:00