-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Expand file tree
/
Copy pathevents.ts
More file actions
758 lines (693 loc) Β· 21.6 KB
/
events.ts
File metadata and controls
758 lines (693 loc) Β· 21.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
/**
* @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 {NavigationBehaviorOptions, Route} from './models';
import type {Navigation} from './navigation_transition';
import {ActivatedRouteSnapshot, RouterStateSnapshot} from './router_state';
import {UrlTree} from './url_tree';
/**
* Identifies the call or event that triggered a navigation.
*
* * 'imperative': Triggered by `router.navigateByUrl()` or `router.navigate()`.
* * 'popstate' : Triggered by a `popstate` event.
* * 'hashchange'-: Triggered by a `hashchange` event.
*
* @publicApi
*/
export type NavigationTrigger = 'imperative' | 'popstate' | 'hashchange';
export const IMPERATIVE_NAVIGATION = 'imperative';
/**
* Identifies the type of a router event.
*
* @see [Router Lifecycle and Events](guide/routing/lifecycle-and-events)
*
* @publicApi
*/
export enum EventType {
NavigationStart,
NavigationEnd,
NavigationCancel,
NavigationError,
RoutesRecognized,
ResolveStart,
ResolveEnd,
GuardsCheckStart,
GuardsCheckEnd,
RouteConfigLoadStart,
RouteConfigLoadEnd,
ChildActivationStart,
ChildActivationEnd,
ActivationStart,
ActivationEnd,
Scroll,
NavigationSkipped,
}
/**
* Base for events the router goes through, as opposed to events tied to a specific
* route. Fired one time for any given navigation.
*
* The following code shows how a class subscribes to router events.
*
* ```ts
* import {Event, RouterEvent, Router} from '@angular/router';
*
* class MyService {
* constructor(public router: Router) {
* router.events.pipe(
* filter((e: Event | RouterEvent): e is RouterEvent => e instanceof RouterEvent)
* ).subscribe((e: RouterEvent) => {
* // Do something
* });
* }
* }
* ```
*
* @see {@link Event}
* @see [Router events summary](guide/routing/router-reference#router-events)
* @publicApi
*/
export class RouterEvent {
constructor(
/** A unique ID that the router assigns to every router navigation. */
public id: number,
/** The URL that is the destination for this navigation. */
public url: string,
) {}
}
/**
* An event triggered when a navigation starts.
*
* @publicApi
*/
export class NavigationStart extends RouterEvent {
readonly type = EventType.NavigationStart;
/**
* Identifies the call or event that triggered the navigation.
* An `imperative` trigger is a call to `router.navigateByUrl()` or `router.navigate()`.
*
* @see {@link NavigationEnd}
* @see {@link NavigationCancel}
* @see {@link NavigationError}
*/
navigationTrigger?: NavigationTrigger;
/**
* The navigation state that was previously supplied to the `pushState` call,
* when the navigation is triggered by a `popstate` event. Otherwise null.
*
* The state object is defined by `NavigationExtras`, and contains any
* developer-defined state value, as well as a unique ID that
* the router assigns to every router transition/navigation.
*
* From the perspective of the router, the router never "goes back".
* When the user clicks on the back button in the browser,
* a new navigation ID is created.
*
* Use the ID in this previous-state object to differentiate between a newly created
* state and one returned to by a `popstate` event, so that you can restore some
* remembered state, such as scroll position.
*
*/
restoredState?: {[k: string]: any; navigationId: number} | null;
constructor(
/** @docsNotRequired */
id: number,
/** @docsNotRequired */
url: string,
/** @docsNotRequired */
navigationTrigger: NavigationTrigger = 'imperative',
/** @docsNotRequired */
restoredState: {[k: string]: any; navigationId: number} | null = null,
) {
super(id, url);
this.navigationTrigger = navigationTrigger;
this.restoredState = restoredState;
}
/** @docs-private */
override toString(): string {
return `NavigationStart(id: ${this.id}, url: '${this.url}')`;
}
}
/**
* An event triggered when a navigation ends successfully.
*
* @see {@link NavigationStart}
* @see {@link NavigationCancel}
* @see {@link NavigationError}
*
* @publicApi
*/
export class NavigationEnd extends RouterEvent {
readonly type = EventType.NavigationEnd;
constructor(
/** @docsNotRequired */
id: number,
/** @docsNotRequired */
url: string,
/** @docsNotRequired */
public urlAfterRedirects: string,
) {
super(id, url);
}
/** @docs-private */
override toString(): string {
return `NavigationEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}')`;
}
}
/**
* A code for the `NavigationCancel` event of the `Router` to indicate the
* reason a navigation failed.
*
* @publicApi
*/
export enum NavigationCancellationCode {
/**
* A navigation failed because a guard returned a `UrlTree` to redirect.
*/
Redirect,
/**
* A navigation failed because a more recent navigation started.
*/
SupersededByNewNavigation,
/**
* A navigation failed because one of the resolvers completed without emitting a value.
*/
NoDataFromResolver,
/**
* A navigation failed because a guard returned `false`.
*/
GuardRejected,
/**
* A navigation was aborted by the `Navigation.abort` function.
*
* @see {@link Navigation}
*/
Aborted,
}
/**
* A code for the `NavigationSkipped` event of the `Router` to indicate the
* reason a navigation was skipped.
*
* @publicApi
*/
export enum NavigationSkippedCode {
/**
* A navigation was skipped because the navigation URL was the same as the current Router URL.
*/
IgnoredSameUrlNavigation,
/**
* A navigation was skipped because the configured `UrlHandlingStrategy` return `false` for both
* the current Router URL and the target of the navigation.
*
* @see {@link UrlHandlingStrategy}
*/
IgnoredByUrlHandlingStrategy,
}
/**
* An event triggered when a navigation is canceled, directly or indirectly.
* This can happen for several reasons including when a route guard
* returns `false` or initiates a redirect by returning a `UrlTree`.
*
* @see {@link NavigationStart}
* @see {@link NavigationEnd}
* @see {@link NavigationError}
*
* @publicApi
*/
export class NavigationCancel extends RouterEvent {
readonly type = EventType.NavigationCancel;
constructor(
/** @docsNotRequired */
id: number,
/** @docsNotRequired */
url: string,
/**
* A description of why the navigation was cancelled. For debug purposes only. Use `code`
* instead for a stable cancellation reason that can be used in production.
*/
public reason: string,
/**
* A code to indicate why the navigation was canceled. This cancellation code is stable for
* the reason and can be relied on whereas the `reason` string could change and should not be
* used in production.
*/
readonly code?: NavigationCancellationCode,
) {
super(id, url);
}
/** @docs-private */
override toString(): string {
return `NavigationCancel(id: ${this.id}, url: '${this.url}')`;
}
}
export function isRedirectingEvent(event: Event): boolean {
return (
event instanceof NavigationCancel &&
(event.code === NavigationCancellationCode.Redirect ||
event.code === NavigationCancellationCode.SupersededByNewNavigation)
);
}
/**
* An event triggered when a navigation is skipped.
* This can happen for a couple reasons including onSameUrlHandling
* is set to `ignore` and the navigation URL is not different than the
* current state.
*
* @publicApi
*/
export class NavigationSkipped extends RouterEvent {
readonly type = EventType.NavigationSkipped;
constructor(
/** @docsNotRequired */
id: number,
/** @docsNotRequired */
url: string,
/**
* A description of why the navigation was skipped. For debug purposes only. Use `code`
* instead for a stable skipped reason that can be used in production.
*/
public reason: string,
/**
* A code to indicate why the navigation was skipped. This code is stable for
* the reason and can be relied on whereas the `reason` string could change and should not be
* used in production.
*/
readonly code?: NavigationSkippedCode,
) {
super(id, url);
}
}
/**
* An event triggered when a navigation fails due to an unexpected error.
*
* @see {@link NavigationStart}
* @see {@link NavigationEnd}
* @see {@link NavigationCancel}
*
* @publicApi
*/
export class NavigationError extends RouterEvent {
readonly type = EventType.NavigationError;
constructor(
/** @docsNotRequired */
id: number,
/** @docsNotRequired */
url: string,
/** @docsNotRequired */
public error: any,
/**
* The target of the navigation when the error occurred.
*
* Note that this can be `undefined` because an error could have occurred before the
* `RouterStateSnapshot` was created for the navigation.
*/
readonly target?: RouterStateSnapshot,
) {
super(id, url);
}
/** @docs-private */
override toString(): string {
return `NavigationError(id: ${this.id}, url: '${this.url}', error: ${this.error})`;
}
}
/**
* An event triggered when routes are recognized.
*
* @publicApi
*/
export class RoutesRecognized extends RouterEvent {
readonly type = EventType.RoutesRecognized;
constructor(
/** @docsNotRequired */
id: number,
/** @docsNotRequired */
url: string,
/** @docsNotRequired */
public urlAfterRedirects: string,
/** @docsNotRequired */
public state: RouterStateSnapshot,
) {
super(id, url);
}
/** @docs-private */
override toString(): string {
return `RoutesRecognized(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`;
}
}
/**
* An event triggered at the start of the Guard phase of routing.
*
* @see {@link GuardsCheckEnd}
*
* @publicApi
*/
export class GuardsCheckStart extends RouterEvent {
readonly type = EventType.GuardsCheckStart;
constructor(
/** @docsNotRequired */
id: number,
/** @docsNotRequired */
url: string,
/** @docsNotRequired */
public urlAfterRedirects: string,
/** @docsNotRequired */
public state: RouterStateSnapshot,
) {
super(id, url);
}
/** @docs-private */
override toString(): string {
return `GuardsCheckStart(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`;
}
}
/**
* An event triggered at the end of the Guard phase of routing.
*
* @see {@link GuardsCheckStart}
*
* @publicApi
*/
export class GuardsCheckEnd extends RouterEvent {
readonly type = EventType.GuardsCheckEnd;
constructor(
/** @docsNotRequired */
id: number,
/** @docsNotRequired */
url: string,
/** @docsNotRequired */
public urlAfterRedirects: string,
/** @docsNotRequired */
public state: RouterStateSnapshot,
/** @docsNotRequired */
public shouldActivate: boolean,
) {
super(id, url);
}
/** @docs-private */
override toString(): string {
return `GuardsCheckEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state}, shouldActivate: ${this.shouldActivate})`;
}
}
/**
* An event triggered at the start of the Resolve phase of routing.
*
* Runs in the "resolve" phase whether or not there is anything to resolve.
* In future, may change to only run when there are things to be resolved.
*
* @see {@link ResolveEnd}
*
* @publicApi
*/
export class ResolveStart extends RouterEvent {
readonly type = EventType.ResolveStart;
constructor(
/** @docsNotRequired */
id: number,
/** @docsNotRequired */
url: string,
/** @docsNotRequired */
public urlAfterRedirects: string,
/** @docsNotRequired */
public state: RouterStateSnapshot,
) {
super(id, url);
}
/** @docs-private */
override toString(): string {
return `ResolveStart(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`;
}
}
/**
* An event triggered at the end of the Resolve phase of routing.
* @see {@link ResolveStart}
*
* @publicApi
*/
export class ResolveEnd extends RouterEvent {
readonly type = EventType.ResolveEnd;
constructor(
/** @docsNotRequired */
id: number,
/** @docsNotRequired */
url: string,
/** @docsNotRequired */
public urlAfterRedirects: string,
/** @docsNotRequired */
public state: RouterStateSnapshot,
) {
super(id, url);
}
/** @docs-private */
override toString(): string {
return `ResolveEnd(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`;
}
}
/**
* An event triggered before lazy loading a route configuration.
*
* @see {@link RouteConfigLoadEnd}
*
* @publicApi
*/
export class RouteConfigLoadStart {
readonly type = EventType.RouteConfigLoadStart;
constructor(
/** @docsNotRequired */
public route: Route,
) {}
/** @docs-private */
toString(): string {
return `RouteConfigLoadStart(path: ${this.route.path})`;
}
}
/**
* An event triggered when a route has been lazy loaded.
*
* @see {@link RouteConfigLoadStart}
*
* @publicApi
*/
export class RouteConfigLoadEnd {
readonly type = EventType.RouteConfigLoadEnd;
constructor(
/** @docsNotRequired */
public route: Route,
) {}
/** @docs-private */
toString(): string {
return `RouteConfigLoadEnd(path: ${this.route.path})`;
}
}
/**
* An event triggered at the start of the child-activation
* part of the Resolve phase of routing.
* @see {@link ChildActivationEnd}
* @see {@link ResolveStart}
*
* @publicApi
*/
export class ChildActivationStart {
readonly type = EventType.ChildActivationStart;
constructor(
/** @docsNotRequired */
public snapshot: ActivatedRouteSnapshot,
) {}
/** @docs-private */
toString(): string {
const path = (this.snapshot.routeConfig && this.snapshot.routeConfig.path) || '';
return `ChildActivationStart(path: '${path}')`;
}
}
/**
* An event triggered at the end of the child-activation part
* of the Resolve phase of routing.
* @see {@link ChildActivationStart}
* @see {@link ResolveStart}
* @publicApi
*/
export class ChildActivationEnd {
readonly type = EventType.ChildActivationEnd;
constructor(
/** @docsNotRequired */
public snapshot: ActivatedRouteSnapshot,
) {}
/** @docs-private */
toString(): string {
const path = (this.snapshot.routeConfig && this.snapshot.routeConfig.path) || '';
return `ChildActivationEnd(path: '${path}')`;
}
}
/**
* An event triggered at the start of the activation part
* of the Resolve phase of routing.
* @see {@link ActivationEnd}
* @see {@link ResolveStart}
*
* @publicApi
*/
export class ActivationStart {
readonly type = EventType.ActivationStart;
constructor(
/** @docsNotRequired */
public snapshot: ActivatedRouteSnapshot,
) {}
/** @docs-private */
toString(): string {
const path = (this.snapshot.routeConfig && this.snapshot.routeConfig.path) || '';
return `ActivationStart(path: '${path}')`;
}
}
/**
* An event triggered at the end of the activation part
* of the Resolve phase of routing.
* @see {@link ActivationStart}
* @see {@link ResolveStart}
*
* @publicApi
*/
export class ActivationEnd {
readonly type = EventType.ActivationEnd;
constructor(
/** @docsNotRequired */
public snapshot: ActivatedRouteSnapshot,
) {}
/** @docs-private */
toString(): string {
const path = (this.snapshot.routeConfig && this.snapshot.routeConfig.path) || '';
return `ActivationEnd(path: '${path}')`;
}
}
/**
* An event triggered by scrolling.
*
* @publicApi
*/
export class Scroll {
readonly type = EventType.Scroll;
constructor(
/** @docsNotRequired */
readonly routerEvent: NavigationEnd | NavigationSkipped,
/** @docsNotRequired */
readonly position: [number, number] | null,
/** @docsNotRequired */
readonly anchor: string | null,
/** @docsNotRequired */
readonly scrollBehavior?: 'manual' | 'after-transition',
) {}
/** @docs-private */
toString(): string {
const pos = this.position ? `${this.position[0]}, ${this.position[1]}` : null;
return `Scroll(anchor: '${this.anchor}', position: '${pos}')`;
}
}
export class BeforeActivateRoutes {}
export class BeforeRoutesRecognized {}
export class RedirectRequest {
constructor(
readonly url: UrlTree,
readonly navigationBehaviorOptions: NavigationBehaviorOptions | undefined,
) {}
}
export type PrivateRouterEvents = BeforeActivateRoutes | RedirectRequest | BeforeRoutesRecognized;
export function isPublicRouterEvent(e: Event | PrivateRouterEvents): e is Event {
return (
!(e instanceof BeforeActivateRoutes) &&
!(e instanceof RedirectRequest) &&
!(e instanceof BeforeRoutesRecognized)
);
}
/**
* Router events that allow you to track the lifecycle of the router.
*
* The events occur in the following sequence:
*
* * [NavigationStart](api/router/NavigationStart): Navigation starts.
* * [RouteConfigLoadStart](api/router/RouteConfigLoadStart): Before
* the router [lazy loads](guide/routing/common-router-tasks#lazy-loading) a route configuration.
* * [RouteConfigLoadEnd](api/router/RouteConfigLoadEnd): After a route has been lazy loaded.
* * [RoutesRecognized](api/router/RoutesRecognized): When the router parses the URL
* and the routes are recognized.
* * [GuardsCheckStart](api/router/GuardsCheckStart): When the router begins the *guards*
* phase of routing.
* * [ChildActivationStart](api/router/ChildActivationStart): When the router
* begins activating a route's children.
* * [ActivationStart](api/router/ActivationStart): When the router begins activating a route.
* * [GuardsCheckEnd](api/router/GuardsCheckEnd): When the router finishes the *guards*
* phase of routing successfully.
* * [ResolveStart](api/router/ResolveStart): When the router begins the *resolve*
* phase of routing.
* * [ResolveEnd](api/router/ResolveEnd): When the router finishes the *resolve*
* phase of routing successfully.
* * [ChildActivationEnd](api/router/ChildActivationEnd): When the router finishes
* activating a route's children.
* * [ActivationEnd](api/router/ActivationEnd): When the router finishes activating a route.
* * [NavigationEnd](api/router/NavigationEnd): When navigation ends successfully.
* * [NavigationCancel](api/router/NavigationCancel): When navigation is canceled.
* * [NavigationError](api/router/NavigationError): When navigation fails
* due to an unexpected error.
* * [Scroll](api/router/Scroll): When the user scrolls.
*
* @publicApi
*/
export type Event =
| NavigationStart
| NavigationEnd
| NavigationCancel
| NavigationError
| RoutesRecognized
| GuardsCheckStart
| GuardsCheckEnd
| RouteConfigLoadStart
| RouteConfigLoadEnd
| ChildActivationStart
| ChildActivationEnd
| ActivationStart
| ActivationEnd
| Scroll
| ResolveStart
| ResolveEnd
| NavigationSkipped;
export function stringifyEvent(routerEvent: Event): string {
switch (routerEvent.type) {
case EventType.ActivationEnd:
return `ActivationEnd(path: '${routerEvent.snapshot.routeConfig?.path || ''}')`;
case EventType.ActivationStart:
return `ActivationStart(path: '${routerEvent.snapshot.routeConfig?.path || ''}')`;
case EventType.ChildActivationEnd:
return `ChildActivationEnd(path: '${routerEvent.snapshot.routeConfig?.path || ''}')`;
case EventType.ChildActivationStart:
return `ChildActivationStart(path: '${routerEvent.snapshot.routeConfig?.path || ''}')`;
case EventType.GuardsCheckEnd:
return `GuardsCheckEnd(id: ${routerEvent.id}, url: '${routerEvent.url}', urlAfterRedirects: '${routerEvent.urlAfterRedirects}', state: ${routerEvent.state}, shouldActivate: ${routerEvent.shouldActivate})`;
case EventType.GuardsCheckStart:
return `GuardsCheckStart(id: ${routerEvent.id}, url: '${routerEvent.url}', urlAfterRedirects: '${routerEvent.urlAfterRedirects}', state: ${routerEvent.state})`;
case EventType.NavigationCancel:
return `NavigationCancel(id: ${routerEvent.id}, url: '${routerEvent.url}')`;
case EventType.NavigationSkipped:
return `NavigationSkipped(id: ${routerEvent.id}, url: '${routerEvent.url}')`;
case EventType.NavigationEnd:
return `NavigationEnd(id: ${routerEvent.id}, url: '${routerEvent.url}', urlAfterRedirects: '${routerEvent.urlAfterRedirects}')`;
case EventType.NavigationError:
return `NavigationError(id: ${routerEvent.id}, url: '${routerEvent.url}', error: ${routerEvent.error})`;
case EventType.NavigationStart:
return `NavigationStart(id: ${routerEvent.id}, url: '${routerEvent.url}')`;
case EventType.ResolveEnd:
return `ResolveEnd(id: ${routerEvent.id}, url: '${routerEvent.url}', urlAfterRedirects: '${routerEvent.urlAfterRedirects}', state: ${routerEvent.state})`;
case EventType.ResolveStart:
return `ResolveStart(id: ${routerEvent.id}, url: '${routerEvent.url}', urlAfterRedirects: '${routerEvent.urlAfterRedirects}', state: ${routerEvent.state})`;
case EventType.RouteConfigLoadEnd:
return `RouteConfigLoadEnd(path: ${routerEvent.route.path})`;
case EventType.RouteConfigLoadStart:
return `RouteConfigLoadStart(path: ${routerEvent.route.path})`;
case EventType.RoutesRecognized:
return `RoutesRecognized(id: ${routerEvent.id}, url: '${routerEvent.url}', urlAfterRedirects: '${routerEvent.urlAfterRedirects}', state: ${routerEvent.state})`;
case EventType.Scroll:
const pos = routerEvent.position
? `${routerEvent.position[0]}, ${routerEvent.position[1]}`
: null;
return `Scroll(anchor: '${routerEvent.anchor}', position: '${pos}')`;
}
}