Skip to content

BreakPointObserver doesn't emit for last subscription if take(1) was used for a previous one #14983

Closed
@ElWoodyl

Description

@ElWoodyl

What is the expected behavior?

On window resize, all the observers are called.

What is the current behavior?

On window resize, the last observer is not called when one of the previous subscription is preceded by a take(1).

What are the steps to reproduce?

https://stackblitz.com/edit/angular-cdk-v7-breakpointobserver-take1-issue

Code:

const breakpoint = this.breakpointObserver.observe([Breakpoints.Small, Breakpoints.Tablet]);
breakpoint.subscribe(value => console.log('1'));
breakpoint.pipe(take(1)).subscribe(value => console.log('2'));
breakpoint.subscribe(value => console.log('3'));
breakpoint.subscribe(value => console.log('4')); // Issue: This observer is not executed on resize due to the pipe(take(1)) done for the second subscription

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

@angular/cdk 7+

Is there anything else we should know?

Works in v6: https://stackblitz.com/edit/angular-cdk-v6-breakpointobserver-take1-no-issue

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions