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

Expose "on" -function #114

Open
swelet opened this issue Jun 1, 2020 · 2 comments
Open

Expose "on" -function #114

swelet opened this issue Jun 1, 2020 · 2 comments

Comments

@swelet
Copy link

swelet commented Jun 1, 2020

Thanks for all the work that you guys do.

I think the Browser.Events.on -function should be exposed.

With the Html.Events.on function we can listen for custom js-events on elements in the Dom. I miss a way of doing the same for Document through subscriptions. Say I want to use a custom drag and drop library in js, I could listen for this event:

someElement.dispatchEvent(new CustomEvent('customDragStart'));

but not make a subscription of this

document.dispatchEvent(new CustomEvent('customDrop'));

I think exposing Browser.Events.on would be both useful and consistent with the api in Html.Events.

@rupertlssmith
Copy link

Would also need to expose Node.

Or expose 'on' functions specalized to window or document:

onWindow : String -> Decode.Decoder msg -> Sub msg
onDocument : String -> Decode.Decoder msg -> Sub msg

@Janiczek
Copy link

This would be useful for "online" and "offline" events that only happen on <body>.

https://developer.mozilla.org/en-US/docs/Web/API/Document/ononline
https://developer.mozilla.org/en-US/docs/Web/API/Document/onoffline

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

3 participants