fix(router): add missing outlet events to RouterOutletContract (#42431)

Exposes both activateEvents and deactivateEvents as the original outlet interface did.

PR Close #42431
This commit is contained in:
Steven Masala 2021-05-31 21:39:55 +02:00 committed by Dylan Hunn
parent 85e93c3833
commit 0d81b007e4
2 changed files with 16 additions and 7 deletions

View File

@ -182,7 +182,6 @@ export type DetachedRouteHandle = {};
// @public // @public
type Event_2 = RouterEvent | RouteConfigLoadStart | RouteConfigLoadEnd | ChildActivationStart | ChildActivationEnd | ActivationStart | ActivationEnd | Scroll; type Event_2 = RouterEvent | RouteConfigLoadStart | RouteConfigLoadEnd | ChildActivationStart | ChildActivationEnd | ActivationStart | ActivationEnd | Scroll;
export { Event_2 as Event } export { Event_2 as Event }
// @public // @public
@ -565,7 +564,7 @@ export class RouterLinkActive implements OnChanges, OnDestroy, AfterContentInit
routerLinkActiveOptions: { routerLinkActiveOptions: {
exact: boolean; exact: boolean;
} | IsActiveMatchOptions; } | IsActiveMatchOptions;
} }
// @public // @public
export class RouterLinkWithHref implements OnChanges, OnDestroy { export class RouterLinkWithHref implements OnChanges, OnDestroy {
@ -627,16 +626,18 @@ export class RouterOutlet implements OnDestroy, OnInit, RouterOutletContract {
ngOnDestroy(): void; ngOnDestroy(): void;
// (undocumented) // (undocumented)
ngOnInit(): void; ngOnInit(): void;
} }
// @public // @public
export interface RouterOutletContract { export interface RouterOutletContract {
activatedRoute: ActivatedRoute | null; activatedRoute: ActivatedRoute | null;
activatedRouteData: Data; activatedRouteData: Data;
activateEvents?: EventEmitter<unknown>;
activateWith(activatedRoute: ActivatedRoute, resolver: ComponentFactoryResolver | null): void; activateWith(activatedRoute: ActivatedRoute, resolver: ComponentFactoryResolver | null): void;
attach(ref: ComponentRef<unknown>, activatedRoute: ActivatedRoute): void; attach(ref: ComponentRef<unknown>, activatedRoute: ActivatedRoute): void;
component: Object | null; component: Object | null;
deactivate(): void; deactivate(): void;
deactivateEvents?: EventEmitter<unknown>;
detach(): ComponentRef<unknown>; detach(): ComponentRef<unknown>;
isActivated: boolean; isActivated: boolean;
} }
@ -650,7 +651,7 @@ export class RouterPreloader implements OnDestroy {
preload(): Observable<any>; preload(): Observable<any>;
// (undocumented) // (undocumented)
setUpPreloading(): void; setUpPreloading(): void;
} }
// @public // @public
export class RouterState extends ɵangular_packages_router_router_m<ActivatedRoute> { export class RouterState extends ɵangular_packages_router_router_m<ActivatedRoute> {
@ -788,7 +789,6 @@ export class UrlTree {
// @public (undocumented) // @public (undocumented)
export const VERSION: Version; export const VERSION: Version;
// (No @packageDocumentation comment for this package) // (No @packageDocumentation comment for this package)
``` ```

View File

@ -6,8 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {Attribute, ChangeDetectorRef, ComponentFactoryResolver, ComponentRef, Directive, EventEmitter, Injector, OnDestroy, OnInit, Output, ViewContainerRef} from '@angular/core'; import {Attribute, ChangeDetectorRef, ComponentFactoryResolver, ComponentRef, Directive, EventEmitter, Injector, OnDestroy, OnInit, Output, ViewContainerRef,} from '@angular/core';
import {Data} from '../config'; import {Data} from '../config';
import {ChildrenOutletContexts} from '../router_outlet_context'; import {ChildrenOutletContexts} from '../router_outlet_context';
import {ActivatedRoute} from '../router_state'; import {ActivatedRoute} from '../router_state';
@ -72,6 +71,16 @@ export interface RouterOutletContract {
* Called when the `RouteReuseStrategy` instructs to re-attach a previously detached subtree. * Called when the `RouteReuseStrategy` instructs to re-attach a previously detached subtree.
*/ */
attach(ref: ComponentRef<unknown>, activatedRoute: ActivatedRoute): void; attach(ref: ComponentRef<unknown>, activatedRoute: ActivatedRoute): void;
/**
* Emits an activate event when a new component is instantiated
**/
activateEvents?: EventEmitter<unknown>;
/**
* Emits a deactivate event when a component is destroyed.
*/
deactivateEvents?: EventEmitter<unknown>;
} }
/** /**