In 0.19, the code
var elmApp = Elm.Main.init({ node: document.getElementById('app') });
elmApp.ports.somePortName.subscribe(whatever);
breaks if somePortName
is declared but not used in the Elm code (I assume that this is due to 0.19’s dead code removal feature).
This actually happened in one of my projects: the same JS module defined two different ports and both were declared Elm-side, but only one was actually used.
If I want my code to be reliable and prevent JS to break unexpectedly, I must add a check to every JS-side port declaration:
elmApp.ports.somePortName && elmApp.ports.somePortName.subscribe(whatever);
This doesn’t seem ideal to me, but seems necessary.
Is this sensible? Am I missing something?