Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upModules cannot have ports with same name #1450
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
process-bot
Jul 26, 2016
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!
Here is what to expect next, and if anyone wants to comment, keep these things in mind.
process-bot
commented
Jul 26, 2016
|
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it! Here is what to expect next, and if anyone wants to comment, keep these things in mind. |
evancz
added
the
ports
label
Sep 21, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
sachin-bs
commented
Nov 6, 2017
|
bump, any updates? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kachkaev
Dec 6, 2017
Just raised a similar concern on stackoverflow. Being a newcomer in Elm, here is what I wanted to do to avoid import glitches:
import MyModule exposing (myFunction as myRenamedFunction, somethingElse)Having that supported by the compiler would be awesome!
kachkaev
commented
Dec 6, 2017
|
Just raised a similar concern on stackoverflow. Being a newcomer in Elm, here is what I wanted to do to avoid import glitches: import MyModule exposing (myFunction as myRenamedFunction, somethingElse)Having that supported by the compiler would be awesome! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
rgrempel
Mar 13, 2018
These two modules are not connected and there should be no ambiguity between the ports.
But think about the way you use the ports, on the Javascript side. You'll end up saying stuff like:
var elmApp = Elm.Main.fullscreen({
...
});
elmApp.ports.cacheCredentials.subscribe(function(params) {
...
}Now, which cacheCredentials does this refer to, if the port name is used in two different modules?
Of course, there would be a way to solve this problem -- you could imagine elmApp.ports exposing a port name qualified by the module name, for instance -- I just wanted to point out that it's not a trivial problem to fix. Or, in other words, there is currently an ambiguity, even if you could imagine deeper changes that might avoid it.
rgrempel
commented
Mar 13, 2018
But think about the way you use the ports, on the Javascript side. You'll end up saying stuff like: var elmApp = Elm.Main.fullscreen({
...
});
elmApp.ports.cacheCredentials.subscribe(function(params) {
...
}Now, which Of course, there would be a way to solve this problem -- you could imagine |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
fdbeirao
Mar 14, 2018
Contributor
I just want to post here that this talk "The Importance of Ports" by Murphy Randle has helped me (YMMV) a lot when using ports in my Elm apps. I now have one single Ports.elm module, which is the only port module and which contains two ports: infoForOutside and infoForElm. This mitigates/works around the ambiguity raised in this issue.
|
I just want to post here that this talk "The Importance of Ports" by Murphy Randle has helped me (YMMV) a lot when using ports in my Elm apps. I now have one single |
b123400 commentedJul 26, 2016
Elm version: 0.17.0
I have two modules, they both have a port with the same name:
And I compiled it by this command:
The generated JS file will output the following error:
These two modules are not connected and there should be no ambiguity between the ports. I think the ports name checking should be bounded to the module, instead of JS-file-wise.
By the way, when I generate the modules separately and include them in the same page, there is no error.
Is this behaviour intended? I can try to send a PR to fix it if it is not :)