Skip to content
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

Typed fromEvent for web #8

Open
waterplea opened this issue Sep 4, 2020 · 0 comments
Open

Typed fromEvent for web #8

waterplea opened this issue Sep 4, 2020 · 0 comments

Comments

@waterplea
Copy link

When we use fromEvent in web we can extract type of event from the map of event names that are present in TypeScript.

It is also often helpful to have currentTarget of that event to have the same type as the target we listen this event on so we do not have to typecast low level EventTarget when we work with it down the RxJS line.

currentTarget type is questionable because it changes. currentTarget only matches the element we listen event on directly in the callback. So this might not be a good idea but it's up for a debate :)

Here's a little proof of concept with events on Element, Window and Document with fallback to current fromEvent behavior where we just have generic:

https://stackblitz.com/edit/angular-typed-fromevent-delux

This could be a starting point for discussion/implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant