Skip to content

Commit 370d3f8

Browse files
committed
refactor: improve type annotations and inline documentation
1 parent 521cde1 commit 370d3f8

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

packages/router-component-store/src/lib/router-history-store/router-history.store.ts

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
Provider,
77
} from '@angular/core';
88
import {
9+
Event as RouterEvent,
910
NavigationCancel,
1011
NavigationEnd,
1112
NavigationError,
@@ -75,9 +76,12 @@ export class RouterHistoryStore extends ComponentStore<RouterHistoryState> {
7576
/**
7677
* All router events.
7778
*/
78-
#routerEvents = this.select(this.#router.events, (events) => events);
79+
#routerEvents: Observable<RouterEvent> = this.select(
80+
this.#router.events,
81+
(events) => events
82+
);
7983
/**
80-
* All router events concluding a navigation.
84+
* All router events concluding a router sequence.
8185
*/
8286
#navigationResult$: Observable<
8387
NavigationEnd | NavigationCancel | NavigationError
@@ -108,15 +112,15 @@ export class RouterHistoryStore extends ComponentStore<RouterHistoryState> {
108112
/**
109113
* The most recent completed navigation.
110114
*/
111-
#latestRouterNavigatedSequence$ = this.select(
112-
this.#maxNavigatedId$,
113-
this.#history$,
114-
(maxNavigatedId, history) =>
115-
history[maxNavigatedId] as RouterNavigatedSequence,
116-
{
117-
debounce: true,
118-
}
119-
);
115+
#latestRouterNavigatedSequence$: Observable<RouterNavigatedSequence> =
116+
this.select(
117+
this.#maxNavigatedId$,
118+
this.#history$,
119+
(maxNavigatedId, history) => history[maxNavigatedId],
120+
{
121+
debounce: true,
122+
}
123+
);
120124

121125
/**
122126
* The current URL.
@@ -139,7 +143,7 @@ export class RouterHistoryStore extends ComponentStore<RouterHistoryState> {
139143
return undefined;
140144
}
141145

142-
const [sourceNavigationStart] = this.#getNavigationSource(
146+
const [sourceNavigationStart] = this.#findNavigatedSource(
143147
maxNavigatedId,
144148
history
145149
);
@@ -149,7 +153,7 @@ export class RouterHistoryStore extends ComponentStore<RouterHistoryState> {
149153
}
150154

151155
const previousNavigationId = sourceNavigationStart.id - 1;
152-
const [, previousNavigationEnd] = this.#getNavigationSource(
156+
const [, previousNavigationEnd] = this.#findNavigatedSource(
153157
previousNavigationId,
154158
history
155159
);
@@ -189,16 +193,16 @@ export class RouterHistoryStore extends ComponentStore<RouterHistoryState> {
189193
);
190194

191195
/**
192-
* Search the specified navigation history to find the source of the
193-
* specified navigation event.
196+
* Search the specified history to find the source of the router navigated
197+
* sequence.
194198
*
195199
* This takes `popstate` navigation events into account.
196200
*
197201
* @param navigationId The ID of the navigation to trace.
198202
* @param history The navigation history to search.
199-
* @returns The source navigation.
203+
* @returns The source router navigated sequence.
200204
*/
201-
#getNavigationSource(
205+
#findNavigatedSource(
202206
navigationId: number,
203207
history: RouterNavigatedHistory
204208
): RouterNavigatedSequence {

0 commit comments

Comments
 (0)