@@ -10,7 +10,7 @@ import {Direction, Directionality} from '@angular/cdk/bidi';
1010import { ComponentPortal , Portal , PortalOutlet , TemplatePortal } from '@angular/cdk/portal' ;
1111import { ComponentRef , EmbeddedViewRef , NgZone } from '@angular/core' ;
1212import { Location } from '@angular/common' ;
13- import { Observable , Subject , merge , SubscriptionLike , Subscription , Observer } from 'rxjs' ;
13+ import { Observable , Subject , merge , SubscriptionLike , Subscription } from 'rxjs' ;
1414import { take , takeUntil } from 'rxjs/operators' ;
1515import { OverlayKeyboardDispatcher } from './keyboard/overlay-keyboard-dispatcher' ;
1616import { OverlayConfig } from './overlay-config' ;
@@ -45,23 +45,9 @@ export class OverlayRef implements PortalOutlet, OverlayReference {
4545 */
4646 private _previousHostParent : HTMLElement ;
4747
48- private _keydownEventsObservable : Observable < KeyboardEvent > =
49- new Observable ( ( observer : Observer < KeyboardEvent > ) => {
50- const subscription = this . _keydownEvents . subscribe ( observer ) ;
51- this . _keydownEventSubscriptions ++ ;
52-
53- return ( ) => {
54- subscription . unsubscribe ( ) ;
55- this . _keydownEventSubscriptions -- ;
56- } ;
57- } ) ;
58-
5948 /** Stream of keydown events dispatched to this overlay. */
6049 _keydownEvents = new Subject < KeyboardEvent > ( ) ;
6150
62- /** Amount of subscriptions to the keydown events. */
63- _keydownEventSubscriptions = 0 ;
64-
6551 constructor (
6652 private _portalOutlet : PortalOutlet ,
6753 private _host : HTMLElement ,
@@ -265,7 +251,7 @@ export class OverlayRef implements PortalOutlet, OverlayReference {
265251
266252 /** Gets an observable of keydown events targeted to this overlay. */
267253 keydownEvents ( ) : Observable < KeyboardEvent > {
268- return this . _keydownEventsObservable ;
254+ return this . _keydownEvents . asObservable ( ) ;
269255 }
270256
271257 /** Gets the current overlay configuration, which is immutable. */
0 commit comments