Hi,
I have the following program:
When I first loaded InitialValue.elm I saw this error:
Port Error:
No argument was given for the port named 'timestamp' with type:
Int
You need to provide an initial value!
Find out more about ports here <http://elm-lang.org/learn/Ports.elm>
Open the developer console for more details.
So I changed
port timestamp : Int
to
port timestamp : Int
port timestamp = 5
However, when I load InitialValue.elm via the elm reactor, I simply see "HelloNaN" (when I expect to see "Hello7").
If I now load index.html which provides its own default value, I see this error:
Port Error:
You provided an argument named 'timestamp' but there is no corresponding port!
Maybe add a port 'timestamp' to your Elm module?
Maybe remove the 'timestamp' argument from your initialization code in JS?
Open the developer console for more details.
If I remove the line port timestamp = 5 and then load the app via index.html, the application correctly displays the current time. However, when I load the .elm file directly, it fails with the original error above.
My questions:
1) Can we please add how to initialise the value of a port to the documentation?
2) Can we change the error message saying 'there is no corresponding port' to one that can actually detect the initialisation of a port?
3) Why does my application compile when giving the port a default value such as '5' when in fact the port returns an invalid Integer? (as I've read from searching, Evan once said that NaN and infinity are not numbers in Elm).
Thanks,
Alex