Commit graph

100 commits

Author SHA1 Message Date
SkyZeroZx
0b08e29f26 test(core): refactors test to use timeout utility
Replaces direct `setTimeout` wrapped in a Promise with the `timeout` helper from `@angular/private/testing`

(cherry picked from commit c15e3a005d)
2026-04-01 20:46:05 +02:00
Matthieu Riegler
c98eab794c refactor(core): remove old resource params
G3 has been cleaned up we can drop those.

(cherry picked from commit 4842f5a3b7)
2026-03-11 17:44:16 +00:00
Matthieu Riegler
835a643161 refactor(core): Support Error like object for on resource errors.
Error like object will be treated as errors.

Related to #61861
2025-12-10 08:18:17 -08:00
David Kingma
0812ac3bec refactor(core): add debugName option to rxjs-interop toSignal
toSignal predates the debugName option for signals to name the signals in the Angular dev-tools This adds the debugName option to toSignal.
2025-11-20 10:49:50 -05:00
SkyZeroZx
0432e76171 docs: Adds links to relevant guides for APIs in core package 2025-11-17 08:47:35 -08:00
Alan Agius
26fed34e0e
build: format md files
This commit configures prettier to format markdown files.
2025-11-06 10:03:05 -08:00
Matthieu Riegler
5ce4d9522d docs: update doc to clear up difference between toObservable/ outputToObservable (#63836)
TLDR: only `toObservable` emits synchronously on subscription.

fixes #57224

PR Close #63836
2025-09-16 15:00:54 +00:00
Andrew Scott
d399d7d02b fix(core): Explicit Zone CD in TestBed providers should not override TestBed error handler (#63404)
The internal error handler in TestBed rethrows errors to prevent them
from being silently ignored in tests. Prior to this commit, tests which
used `provideZoneChangeDetection` in the providers would override the
internal error handler of TestBed and prevent these errors from being
rethrown.

BREAKING CHANGE: (test only) - Using `provideZoneChangeDetection` in the
TestBed providers would previously prevent `TestBed` from rethrowing
errors as it should. Errors in the test will now be rethrown, regardless
of the usage of `provideZoneChangeDetection`. Tests should be adjusted to
prevent or account for these errors. As in previous major versions,
this behavior can be disabled with `rethrowApplicationErrors: false` in
`configureTestingModule` as a last resort.

PR Close #63404
2025-09-02 09:26:44 -07:00
Vincent
9ae9875384 fix(core): Prevent an error on cleanup when an rxResource stream threw before returning an Observable (#63342)
Before this commit, it was wrongly assumed that the stream subscription could not be `undefined`.

Fixes #63341

PR Close #63342
2025-08-28 08:44:51 -07:00
Joey Perrott
2fcafb65c5 build: rename defaults2.bzl to defaults.bzl (#63383)
Use defaults.bzl for the common macros

PR Close #63383
2025-08-25 15:45:01 -07:00
Joey Perrott
3df1dccebe refactor: various build and import specificer fixes for strict deps (#63323)
Change direct deps in bazel targets and import specifiers within files to maintain strict deps requirements ahead of enabling strict deps tests in the repo

PR Close #63323
2025-08-22 14:45:00 -07:00
Joey Perrott
cbc258eec8 build: remove ts_project_interop infrastructure (#62908)
Remove the interop macros and final usages

PR Close #62908
2025-07-31 09:12:58 +00:00
Joey Perrott
793ff35602 build: move http_server and generate_api_docs into defaults2.bzl (#62878)
Move http_server and generate_api_docs into defaults2.bzl as they are rules_js compliant

PR Close #62878
2025-07-29 16:53:54 +00:00
Joey Perrott
8bf97d1370 build: remove all usages of the interop_deps attr for ts_project and ng_project (#62732)
Remove all of the usages of interop_deps as attributes in the repo

PR Close #62732
2025-07-21 13:03:09 -04:00
Joey Perrott
b84859073b build: migrate to use web test runner rules (#62292)
Migrate karma tests throughout the repo to use the new web test runner based rule instead

PR Close #62292
2025-06-26 17:19:10 +00:00
Joey Perrott
3a0cfd544d build: migrate to using new jasmine_test (#62086)
Use the new jasmine_test based on rules_js instead of jasmine_node_test from rules_nodejs

PR Close #62086
2025-06-18 08:27:26 +02:00
arturovt
e81ea0c3dd fix(core): unregister onDestroy in outputToObservable (#61882)
We should remove the `onDestroy` listener once subscription is unsubscribed because components might not be destroyed yet, but they still would capture subscribers.

PR Close #61882
2025-06-05 11:16:57 +02:00
Andrew Scott
8163a8995e feat(core): Add destroyed property on DestroyRef (#61849)
Since `DestroyRef.onDestroy` throws if the `DestroyRef` is already
destroyed, there is a need to be able to tell if it is already destroyed
before attempting to register a callback.

PR Close #61849
2025-06-04 14:14:55 -04:00
Andrew Scott
2bd3a43028 fix(core): takeUntilDestroyed completes immediately if DestroyRef already destroyed (#61847)
Adds fix directly for `takeUntilDestroyed` to unsubscribe when already
destroyed instead of putting
synchronous behavior on `DestroyRef.onDestroyed` callback as in #58008

fixes #54527

PR Close #61847
2025-06-04 12:14:15 -04:00
cexbrayat
dcfbe6c811 refactor(core): use RefactorStreamItem type in rxResource (#59887)
The `ResourceStreamItem` was introduced in #59851 and can be used to simplify the `rxResource` code.

PR Close #59887
2025-06-04 11:45:04 -04:00
arturovt
f37b2f7650 fix(core): unregister onDestroy when observable errors in toSignal (#61596)
The observable terminates immediately when `error` is called, and no further emissions or completion notifications occur. Thus, we have to remove the listener in both the `error` and `complete` notifications.

PR Close #61596
2025-06-04 09:36:41 -04:00
Matthieu Riegler
fe03aa09ad Revert "fix(core): call DestroyRef on destroy callback if view is destroyed (#58008)" (#61625)
This reverts commit 5f7f04634f.

PR Close #61625
2025-05-27 15:21:20 -07:00
Maciej Sawicki
05eb028c7a fix(core): narrow error type for resources API (#61441)
`Resource.error` used to return `unknown`. Now it's `Error | undefined`.
For non-`Error` types they are encapsulated with the `Error` type.

PR Close #61441
2025-05-21 12:06:40 -07:00
arturovt
93e8565f0e fix(core): cleanup rxResource abort listener (#58306)
The observable terminates immediately when `error` is called, and no further emissions or completion notifications occur. Thus, we have to remove the `abort` listener in both the `error` and `complete` notifications.

PR Close #58306
2025-05-21 15:17:22 +00:00
arturovt
e7656b84b2 refactor(core): drop rxResource error messages (#61565)
Drops `rxResource` error messages in production and replaces with error codes.

PR Close #61565
2025-05-21 12:42:59 +00:00
arturovt
62185714b5 refactor(core): drop injection context assertion in production (#61564)
In other parts of the code, calls to the `assertInInjectionContext` function are guarded with `ngDevMode`. This change aligns these parts of the code with other implementations that drop such assertions in production.

PR Close #61564
2025-05-21 12:42:10 +00:00
arturovt
9416483bd3 refactor(core): drop injection context assertion in production (#61560)
In other parts of the code, calls to the `assertInInjectionContext` function are guarded with `ngDevMode`. This change aligns these parts of the code with other implementations that drop such assertions in production.

PR Close #61560
2025-05-21 11:35:47 +00:00
Matthieu Riegler
1148b7e0c5 fix(core): unregister onDestroy in toSignal. (#61514)
We cleanup if the observable completes before the onDestroy fires.

fixes #61511

PR Close #61514
2025-05-20 14:43:31 +00:00
Paul Gschwendtner
d067dff394 build: migrate more targets of @angular/core to ts_project (#61370)
Migrates more targets of `@angular/core` to `ts_project`. Remaining are:

 - tests
 - schematics

PR Close #61370
2025-05-16 11:02:07 +00:00
Paul Gschwendtner
032b802f54 build: remove irrelevant madge circular deps tests (#61156)
We don't need this tooling anymore because we are already validating
that there are no circular dependencies via the `ng-dev` tooling that
checks `.ts` files directly.

Also these tests never actually failed to my knowledge.

PR Close #61156
2025-05-07 11:28:59 -07:00
Andrew Scott
e7f5aa2b52 refactor(core): Remove use of private export PendingTasksInternal where possible (#61049)
This commit removes the use of the privately exported
PendingTasksInternal everywhere except for Router. A follow-up change
will be done to remove that one as well and delete the private export.

PR Close #61049
2025-05-05 08:56:20 -07:00
Matthieu Riegler
f580318411 docs(docs-infra): Add version of introduction for APIs (#60814)
For new APIs we'll mention since when a particular API is in its current status (experimental, devPreview, stable)

fixes #49668

PR Close #60814
2025-05-02 07:51:33 -07:00
Alex Rickabaugh
4bcf1831d9 refactor(core): rename loader parameter to stream for rxResource (#60919)
As decided in the Resource RFC, this commit renames `loader` in `rxResource`
to `stream`. Some logic is left in to support gradual rollout of this change
in g3.

PR Close #60919
2025-04-23 19:34:50 +00:00
Alex Rickabaugh
d0c9a6401a refactor(core): rename resource's request to params (#60919)
As decided in the resource RFC, this commit renames the `request` option of
a resource to `params`, including the subsequent argument passed to the
loader. It also corrects the type in the process to properly allow narrowing
of the `undefined` value.

Fixes #58871

PR Close #60919
2025-04-23 19:34:50 +00:00
Matthieu Riegler
2f3f8d6d3b refactor(core): promote pendingUntilEvent to developerPreview (#60904)
`pendingUntilEvent` is now in developerPreview in v20.

PR Close #60904
2025-04-18 12:32:59 +02:00
Matthieu Riegler
e50f8a23dc Revert "refactor(core): use stream in rxResource instead of loader (#59910)" (#60803)
This reverts commit 98a584c1e8.

PR Close #60803
2025-04-09 09:33:26 -07:00
cexbrayat
98a584c1e8 refactor(core): use stream in rxResource instead of loader (#59910)
With the changes in #59573, `resource` can now define a `stream` rather than a `loader`.
In the same PR, `rxResource` was updated to leverage this new functionality to handle multiple responses from the underlying observable,
rather than just the first one as it was previously.
This commit renames the `loader` option of `rxResource` into `stream` to be better aligned with its new behavior.

The previous version is temporarily kept and marked as deprecated to help migrating the current usage.

Before
```
usersResource = rxResource({
  request: () => ...,
  loader: ({ request }) => ...
});
```

After
```
usersResource = rxResource({
  request: () => ...,
  stream: ({ request }) => ...
});
```

PR Close #59910
2025-04-08 10:19:13 -07:00
Jamie Couperwhite
a1a9f8c1a9 docs: fix typo in documentation for pendingUntilEvent (#60756)
PR Close #60756
2025-04-07 10:29:35 -07:00
Alex Rickabaugh
4e88e18a8e feat(core): mark toObservable as stable (#60449)
`toObservable` graduates from developer preview and is now considered stable
API.

PR Close #60449
2025-04-02 13:38:49 -07:00
Alex Rickabaugh
45f909e8f9 Revert "refactor(core): support an opt-in sync version of toObservable (#60640)" (#60449)
This reverts commit 57a240b07e. We're no
longer attempting to convert `toObservable` to a synchronous API.

PR Close #60449
2025-04-02 13:38:49 -07:00
arturovt
1c7b356625 fix(core): release hasPendingTasks observers (#59723)
In this commit, we unsubscribe the `hasPendingTasks` subject to remove all active observers and enable granular garbage collection, as users may forget to unsubscribe manually when subscribing to `isStable`.

PR Close #59723
2025-04-02 18:26:06 +00:00
arturovt
5f7f04634f fix(core): call DestroyRef on destroy callback if view is destroyed (#58008)
In this commit, we introduce the ability to check whether `lView` has already been
destroyed in `NodeInjectorDestroyRef`. If the `lView` is already destroyed, we call
the on-destroy callback immediately, without trying to register it to be called later.
This ensures that any necessary cleanup is handled gracefully and provides better
reliability in managing resources.

One of the use cases is `takeUntilDestroyed`, which aims to replace `takeUntil` in existing
applications. While `takeUntil` can be safely called once the view is destroyed—resulting
in no errors and finalizing the subscription depending on whether a subject or replay
subject is used—replacing it with `takeUntilDestroyed` introduces a breaking change, as
it throws an error if the `lView` is destroyed.

Related issue: #54527

PR Close #58008
2025-04-02 15:24:48 +00:00
Alex Rickabaugh
57a240b07e refactor(core): support an opt-in sync version of toObservable (#60640)
This commit adds a flag `forceSyncFirstEmit` which opts in to the pending
new behavior for `toObservable`, which emits the first value synchronously.
This flag is only really meant for use during a short migration period
while we update g3, and is not meant for prolonged usage. As a result, it's
marked deprecated.

PR Close #60640
2025-04-01 15:56:39 +00:00
Benjamin Pabst
765ba1e181 fix(core): check ngDevMode for undefined (#60565)
This adds a check to "toSignal" whether ngDevMode is not undefined as this can happen for some MFE applications.

PR Close #60565
2025-03-27 20:25:40 +00:00
Andrew Kushnir
33c24624be refactor(core): convert scripts within packages/core/rxjs-interop to relative imports (#60232)
This commit updates scripts within `packages/core/rxjs-interop` to relative imports as a prep work to the upcoming infra updates.

PR Close #60232
2025-03-27 18:29:35 +00:00
Pawel Kozlowski
644d9f3bbd feat(core): mark the toSignal API as stable (#60442)
This commit marks the toSignal API as stable.

PR Close #60442
2025-03-19 08:38:44 +01:00
Andrew Scott
48974c3cf8 fix(core): remove rejectErrors option encourages uncaught exceptions (#60397)
This commit removes the previously added `rejectErrors` option from
`toSignal` which was meant to create similar behavior to what happens
with unhandled errors in `AsyncPipe`.

This option promotes unhandled exceptions and attaches behaviors that we
do not believe are desirable as an option offered by the framework:

* Unhandled errors that are thrown lose the context of where the error
  ocurred. Throwing the error where the signal is read allows error
  handling to be performed at the signal's usage location
* With this feature, the value of the signal remains set to the initial
  value or the previous successful value coming out of the `Observable`.
  We do not feel this is appropriate implicit behavior but should be an
  explicit choice by the application. Signals are built to represent
  state. When an observable stream is converted to a stateful
  representation, there should be a choice made about what state should
  be presented when an error occurs
* If an error occurs but the signal value is never read in its error
  state, this is not an application state error that should result in an
  unhandled exception.
* While Angular does not have error boundaries today, there is likely to
  be investigation in the near future to address increased risk of
  errors thrown from signals such as this in templates. Without
  pre-designing any specifics, it is possible that this type of feature
  would require the error to be thrown from the signal. We are subsequently
  not prepared to commit to stabilizing the `toSignal` API with the
  `rejectErrors` option and its current behavior.

Developers that desire similar behavior to `rejectErrors` have several
options, the simplest of which would be something similar to
`toSignal(myStream.pipe(catchError(() => EMPTY)))`.

PR Close #60397
2025-03-18 14:10:24 +01:00
Andrew Scott
02cb7e061a refactor(core): remove microtask effect (#60234)
This has been removed internally and was never exposed externally (it was a breaking change)

PR Close #60234
2025-03-06 12:48:55 -08:00
Kristiyan Kostadinov
4853129a7d test(core): clean up explicit standalone flags from tests (#60062)
Now that standalone is the default, we don't need to specify it in tests anymore.

PR Close #60062
2025-02-24 11:27:44 -05:00
Alex Rickabaugh
b592b1b051 fix(core): fix race condition in resource() (#59851)
The refactoring of `resource()` to use `linkedSignal()` introduced the
potential for a race condition where resources would get stuck and not update
in response to a request change. This occurred under a specific condition:

1. The request changes while the resource is still in loading state
2. The resource resolves the previous load before its `effect()` reacts to the
   request change.

In practice, the window for this race is small, because the request change in
(1) will schedule the effect in (2) immediately. However, it's easier to
trigger this sequencing in tests, especially when one resource depends on the
output of another.

To fix the race condition, the resource impl is refactored to track the request
in its state, and ignore resolved values or streams for stale requests. This
refactoring actually makes the resource code simpler and easier to follow as
well.

Fixes #59842

PR Close #59851
2025-02-05 15:01:02 -08:00