Skip to content

Commit

Permalink
fix(router): add missing outlet events to RouterOutletContract (#42431)
Browse files Browse the repository at this point in the history
Exposes both activateEvents and deactivateEvents as the original outlet interface did.

PR Close #42431
  • Loading branch information
smasala authored and dylhunn committed Jul 27, 2021
1 parent 85e93c3 commit 0d81b00
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
10 changes: 5 additions & 5 deletions goldens/public-api/router/router.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -565,7 +564,7 @@ export class RouterLinkActive implements OnChanges, OnDestroy, AfterContentInit
routerLinkActiveOptions: {
exact: boolean;
} | IsActiveMatchOptions;
}
}

// @public
export class RouterLinkWithHref implements OnChanges, OnDestroy {
Expand Down Expand Up @@ -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;
}
Expand All @@ -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> {
Expand Down Expand Up @@ -788,7 +789,6 @@ export class UrlTree {
// @public (undocumented)
export const VERSION: Version;


// (No @packageDocumentation comment for this package)

```
13 changes: 11 additions & 2 deletions packages/router/src/directives/router_outlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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>;
}

/**
Expand Down

0 comments on commit 0d81b00

Please sign in to comment.