-
Notifications
You must be signed in to change notification settings - Fork 771
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(breakpoints): add global provider for BreakPointRegistry
* Fix issue with breakpoints not activating because the new breakpoints token is emptied when BreakPointRegistry is injected again
- Loading branch information
1 parent
84ca5c3
commit 7cedf6f
Showing
2 changed files
with
39 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
import {InjectionToken, Optional, SkipSelf} from '@angular/core'; | ||
|
||
import {BreakPointRegistry} from './break-point-registry'; | ||
import {BreakPoint} from './break-point'; | ||
import {BREAKPOINTS} from './break-points-token'; | ||
|
||
/** | ||
* Ensure a single global service provider | ||
*/ | ||
export function BREAKPOINT_REGISTRY_PROVIDER_FACTORY(parentRegistry: BreakPointRegistry, | ||
breakpoints: BreakPoint[]) { | ||
return parentRegistry || new BreakPointRegistry(breakpoints); | ||
} | ||
|
||
|
||
/** | ||
* Export provider that uses a global service factory (above) | ||
*/ | ||
export const BREAKPOINT_REGISTRY_PROVIDER = { | ||
provide: BreakPointRegistry, | ||
deps: [ | ||
[new Optional(), new SkipSelf(), BreakPointRegistry], | ||
<InjectionToken<BreakPoint[]>>BREAKPOINTS, | ||
], | ||
useFactory: BREAKPOINT_REGISTRY_PROVIDER_FACTORY | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters