Skip to content

cleanup(cdk-scrollable): use fromEvent under the hood #12589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2018

Conversation

mmalerba
Copy link
Contributor

@mmalerba mmalerba commented Aug 8, 2018

technically a major change since I'm switching the Observable from <any> to <Event>

@mmalerba mmalerba added the target: major This PR is targeted for the next major release label Aug 8, 2018
@mmalerba mmalerba requested a review from crisbeto August 8, 2018 17:02
@mmalerba mmalerba requested a review from andrewseguin as a code owner August 8, 2018 17:02
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Aug 8, 2018
private _scrollListener = (event: Event) => this._elementScrolled.next(event);
private _destroyed = new Subject();

private _elementScrolled: Observable<Event> = Observable.create(observer =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need the Observable.create here? You can just do this:

private _elementScrolled = this._ngZone.runOutsideAngular(() => {
  return fromEvent(...).pipe(takeUntil(this._destroyed), tap(() => ...));
});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the tap(() => ...) do here?

I was under the impression that the call to subscribe has to occur inside the runOutsideAngular function, that's why I did it this way

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I forgot that about having to subscribe.

Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

private _scrollListener = (event: Event) => this._elementScrolled.next(event);
private _destroyed = new Subject();

private _elementScrolled: Observable<Event> = Observable.create(observer =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I forgot that about having to subscribe.

@crisbeto crisbeto added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Aug 9, 2018
@mmalerba mmalerba merged commit fceb7af into angular:master Aug 13, 2018
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants