Nice way to pass no data through port?

I want to call a js function from elm that doesn’t need any parameters. I first tried to use the type:

msg -> Sub msg

but the port seems to need to be of a type like:

(something -> msg) -> Sub msg

so i tried to use an empty tuple and an empty array on js side which didnt work for some reason, but then I used an empty struct instead which did work.

But now I was just wondering if there is a prettier solution without passing unnessesary data.
I guess there isn’t given how the port type needs to be. But maybe I’m missing something


You can have a port like:
port noData : (() -> msg) -> Sub msg
and use it in your JS code like so:


This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.