refactor(router): Create transactional router resource#69490
Open
atscott wants to merge 1 commit into
Open
Conversation
JeanMeche
reviewed
Jun 23, 2026
| injector, | ||
| ); | ||
|
|
||
| const res = resourceFromSnapshots(snapshotSignal) as Resource<T> & {reload(): boolean}; |
Member
There was a problem hiding this comment.
Side conversation, this reminds me of #67124. We might want to have such feature in the public api.
Contributor
Author
There was a problem hiding this comment.
Yea, it's a bit of that which seems to also be a consequence of Resource not having reload. It's only on WritableResource but it feels to me like reload is quite different from the set of WritableResource and could arguably be in the base Resource interface
0f1ba79 to
76aa561
Compare
This commit adds an implementation of a router resource (not currently exposed for public use) which defines the behavior of a resource dependent on the Router navigation lifecycle. The cooperative router resource has the following behaviors: * **Universal Resource Support**: Because the wrapper operates on the standard `Resource<T>` base interface, it natively and transparently supports wrapping any compliant resource implementation (such as `resource()` or `rxResource()`) out-of-the-box. * **Transactional Freezing**: During navigation, the state of the resource (value, status, error, and loading signals) is frozen so the application state and UI do not eagerly change/flash during an in-progress navigation. * **Rollback Recovery**: On a true rollback cancellation, it retains the frozen snapshot (to prevent a loading flash of the previous state) until the resource successfully finishes reloading the rolled-back state. * **Immediate Recovery Cancellation**: If the frozen state was not a valid settled state (e.g. was in 'error'), it bypasses the recovery phase and unfreezes immediately on rollback. * **New Navigation Preemption**: Starting a new navigation immediately preempts and clears any pending rollback recovery. * **Cooperative API Surface**: It omits writable APIs (set/update) to prevent out-of-band mutations that bypass the transactional freeze, and only exposes a minification-safe `reload()` method that is disabled during active navigations.
76aa561 to
e39a22b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit adds an implementation of a router resource (not currently exposed for public use) which
defines the behavior of a resource dependent on the Router navigation lifecycle.
The cooperative router resource has the following behaviors:
Resource<T>base interface, it natively and transparently supports wrapping any compliant resource implementation (such asresource()orrxResource()) out-of-the-box.reload()method that is disabled during active navigations.