-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Conversation
private _scrollListener = (event: Event) => this._elementScrolled.next(event); | ||
private _destroyed = new Subject(); | ||
|
||
private _elementScrolled: Observable<Event> = Observable.create(observer => |
There was a problem hiding this comment.
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(() => ...));
});
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this 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 => |
There was a problem hiding this comment.
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.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
technically a major change since I'm switching the
Observable
from<any>
to<Event>