Skip to content

Commit 23dca21

Browse files
committed
move overlay providers in individual files
1 parent d7e1d03 commit 23dca21

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

src/lib/core/overlay/overlay-container.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Injectable} from '@angular/core';
1+
import {Injectable, Optional, SkipSelf} from '@angular/core';
22

33

44
/**
@@ -31,3 +31,12 @@ export class OverlayContainer {
3131
this._containerElement = container;
3232
}
3333
}
34+
35+
export const OVERLAY_CONTAINER_PROVIDER = {
36+
// If there is already an OverlayContainer available, use that. Otherwise, provide a new one.
37+
provide: OverlayContainer,
38+
deps: [[new Optional(), new SkipSelf(), OverlayContainer]],
39+
useFactory: (parentContainer: OverlayContainer) => {
40+
return parentContainer || new OverlayContainer();
41+
}
42+
};

src/lib/core/overlay/overlay.ts

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@ import {
44
ApplicationRef,
55
Injector,
66
NgZone,
7-
Optional,
8-
SkipSelf,
97
Provider,
108
} from '@angular/core';
119
import {OverlayState} from './overlay-state';
1210
import {DomPortalHost} from '../portal/dom-portal-host';
1311
import {OverlayRef} from './overlay-ref';
1412
import {OverlayPositionBuilder} from './position/overlay-position-builder';
1513
import {VIEWPORT_RULER_PROVIDER} from './position/viewport-ruler';
16-
import {OverlayContainer} from './overlay-container';
17-
import {ScrollDispatcher} from './scroll/scroll-dispatcher';
14+
import {OverlayContainer, OVERLAY_CONTAINER_PROVIDER} from './overlay-container';
15+
import {SCROLL_DISPATCHER_PROVIDER} from './scroll/scroll-dispatcher';
1816

1917

2018
/** Next overlay unique ID. */
@@ -96,20 +94,6 @@ export const OVERLAY_PROVIDERS: Provider[] = [
9694
Overlay,
9795
OverlayPositionBuilder,
9896
VIEWPORT_RULER_PROVIDER,
99-
{
100-
// If there is already an ScrollDispatcher available, use that. Otherwise, provide a new one.
101-
provide: ScrollDispatcher,
102-
deps: [[new Optional(), new SkipSelf(), ScrollDispatcher]],
103-
useFactory: (parentDispatcher: ScrollDispatcher) => {
104-
return parentDispatcher || new ScrollDispatcher();
105-
}
106-
},
107-
{
108-
// If there is already an OverlayContainer available, use that. Otherwise, provide a new one.
109-
provide: OverlayContainer,
110-
deps: [[new Optional(), new SkipSelf(), OverlayContainer]],
111-
useFactory: (parentContainer: OverlayContainer) => {
112-
return parentContainer || new OverlayContainer();
113-
}
114-
}
97+
SCROLL_DISPATCHER_PROVIDER,
98+
OVERLAY_CONTAINER_PROVIDER,
11599
];

src/lib/core/overlay/scroll/scroll-dispatcher.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Injectable, ElementRef} from '@angular/core';
1+
import {Injectable, ElementRef, Optional, SkipSelf} from '@angular/core';
22
import {Scrollable} from './scrollable';
33
import {Subject} from 'rxjs/Subject';
44
import {Observable} from 'rxjs/Observable';
@@ -88,3 +88,11 @@ export class ScrollDispatcher {
8888
}
8989
}
9090

91+
export const SCROLL_DISPATCHER_PROVIDER = {
92+
// If there is already an ScrollDispatcher available, use that. Otherwise, provide a new one.
93+
provide: ScrollDispatcher,
94+
deps: [[new Optional(), new SkipSelf(), ScrollDispatcher]],
95+
useFactory: (parentDispatcher: ScrollDispatcher) => {
96+
return parentDispatcher || new ScrollDispatcher();
97+
}
98+
};

0 commit comments

Comments
 (0)