Skip to content

Commit a6cdcfc

Browse files
jerome-nelsonjelbourn
authored andcommitted
refactor(schematics): allow subscription sharing on isHandset$ (#16453)
1 parent 2654bd1 commit a6cdcfc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/material/schematics/ng-generate/nav/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.ts.template

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component<% if(!!viewEncapsulation) { %>, ViewEncapsulation<% }%><% if(changeDetection !== 'Default') { %>, ChangeDetectionStrategy<% }%> } from '@angular/core';
22
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
33
import { Observable } from 'rxjs';
4-
import { map } from 'rxjs/operators';
4+
import { map, share } from 'rxjs/operators';
55

66
@Component({
77
selector: '<%= selector %>',<% if(inlineTemplate) { %>
@@ -20,7 +20,8 @@ export class <%= classify(name) %>Component {
2020

2121
isHandset$: Observable<boolean> = this.breakpointObserver.observe(Breakpoints.Handset)
2222
.pipe(
23-
map(result => result.matches)
23+
map(result => result.matches),
24+
share()
2425
);
2526

2627
constructor(private breakpointObserver: BreakpointObserver) {}

0 commit comments

Comments
 (0)