You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yesterday I installed Elm 0.19.1 yesterday and started playing with it. I have read the entire guide.
Today I wanted to try using a port. I changed my module declaration and defined the port. Then I edited my index.html to send a value to the port. I got a Javascript error:
Uncaught TypeError: Cannot read property 'myPort' of undefined
After too much time poking around in the Javascript debugger and a little Googling, I discovered that Elm (as of 0.19 apparently) discards ports that aren't used on the Elm side. I don't recall reading about this in the guide. I cannot find any mention of it on the Ports page of the guide. Anyway, adding a subscription to the port fixed the problem.
I also joined the Elm slack today and this evening at 8:04 PM US/Central time, in the #beginners channel, someone else asked about the same problem.
It would be nice for the guide to explain that a port must be used on the Elm side or else it won't be available on the Javascript side and will trigger this specific error.
The text was updated successfully, but these errors were encountered:
Did you discover the exact piece of code where Elm would discard the unused ports?
FWIW, I've gotten the same error too, and it's just been invalid browser cache. The browser hadn't loaded the updated elm.js containing the port definition. In this case a simple shift-cmd-r i.e. hard reload helped me.
Yesterday I installed Elm 0.19.1 yesterday and started playing with it. I have read the entire guide.
Today I wanted to try using a port. I changed my module declaration and defined the port. Then I edited my index.html to send a value to the port. I got a Javascript error:
After too much time poking around in the Javascript debugger and a little Googling, I discovered that Elm (as of 0.19 apparently) discards ports that aren't used on the Elm side. I don't recall reading about this in the guide. I cannot find any mention of it on the Ports page of the guide. Anyway, adding a subscription to the port fixed the problem.
I also joined the Elm slack today and this evening at 8:04 PM US/Central time, in the #beginners channel, someone else asked about the same problem.
It would be nice for the guide to explain that a port must be used on the Elm side or else it won't be available on the Javascript side and will trigger this specific error.
The text was updated successfully, but these errors were encountered: