Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • I believe this is a error: this.height$ = (windowSize$.pluck('height') as Observable<number>).distinctUntilChanged();Observable<number>).distinctUntilChanged(); looks like you pasted in the distinctUntilChanged() twice in a row Commented Jan 24, 2017 at 14:44
  • I did not get you, eloborate please. Commented May 22, 2017 at 14:00
  • Change detection won't be fired as you're doing this event outside of Angular, believe that's what he meant. Commented Jun 20, 2017 at 14:36
  • 1
    I had an error saying 'pluck' does not exist on type BehaviorSubject. Changing the code to this.height$ = windowSize$.map(x => x.height) worked for me. Commented Jul 7, 2017 at 11:51
  • 1
    in the service constructor, you have to use .pipe() to use distinctUntilChanged(), pluck() and map(), both imported from rxjs/operators used like this: .pipe(map()). Also, just use fromEvent() imported directly from rxjs instead of Observable.fromEvent() Commented Sep 20, 2021 at 4:07