@@ -16,7 +16,7 @@ import {
16
16
validateHorizontalPosition ,
17
17
validateVerticalPosition ,
18
18
} from './connected-position' ;
19
- import { Observable , Subscription , Subject , Observer } from 'rxjs' ;
19
+ import { Observable , Subscription , Subject } from 'rxjs' ;
20
20
import { OverlayReference } from '../overlay-reference' ;
21
21
import { isElementScrolledOutsideView , isElementClippedByScrolling } from './scroll-clip' ;
22
22
import { coerceCssPixelValue , coerceArray } from '@angular/cdk/coercion' ;
@@ -115,9 +115,6 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
115
115
/** Selector to be used when finding the elements on which to set the transform origin. */
116
116
private _transformOriginSelector : string ;
117
117
118
- /** Amount of subscribers to the `positionChanges` stream. */
119
- private _positionChangeSubscriptions = 0 ;
120
-
121
118
/** Keeps track of the CSS classes that the position strategy has applied on the overlay panel. */
122
119
private _appliedPanelClasses : string [ ] = [ ] ;
123
120
@@ -126,18 +123,10 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
126
123
127
124
/** Observable sequence of position changes. */
128
125
positionChanges : Observable < ConnectedOverlayPositionChange > =
129
- new Observable ( ( observer : Observer < ConnectedOverlayPositionChange > ) => {
130
- const subscription = this . _positionChanges . subscribe ( observer ) ;
131
- this . _positionChangeSubscriptions ++ ;
132
-
133
- return ( ) => {
134
- subscription . unsubscribe ( ) ;
135
- this . _positionChangeSubscriptions -- ;
136
- } ;
137
- } ) ;
126
+ this . _positionChanges . asObservable ( ) ;
138
127
139
128
/** Ordered list of preferred positions, from most to least desirable. */
140
- get positions ( ) {
129
+ get positions ( ) : ConnectionPositionPair [ ] {
141
130
return this . _preferredPositions ;
142
131
}
143
132
@@ -667,7 +656,7 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
667
656
// Notify that the position has been changed along with its change properties.
668
657
// We only emit if we've got any subscriptions, because the scroll visibility
669
658
// calculcations can be somewhat expensive.
670
- if ( this . _positionChangeSubscriptions > 0 ) {
659
+ if ( this . _positionChanges . observers . length ) {
671
660
const scrollableViewProperties = this . _getScrollVisibility ( ) ;
672
661
const changeEvent = new ConnectedOverlayPositionChange ( position , scrollableViewProperties ) ;
673
662
this . _positionChanges . next ( changeEvent ) ;
0 commit comments