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

View File

@ -6,8 +6,7 @@
* 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 {ChildrenOutletContexts} from '../router_outlet_context';
import {ActivatedRoute} from '../router_state';
@ -72,6 +71,16 @@ export interface RouterOutletContract {
* Called when the `RouteReuseStrategy` instructs to re-attach a previously detached subtree.
*/
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>;
}
/**