-
Notifications
You must be signed in to change notification settings - Fork 362
Description
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.