I have come across this problem aswell. I made an example that illustrates this issue when composing the spellchecker described in the guide <http://guide.elm-lang.org/interop/javascript.html>. It can be found ar besuikerd/port-clash <https://github.com/besuikerd/port-clash>. AFAIK The only solution for now is a native implementation, which is not ideal. A solution, as also described in the repo, would be a local port that has the input and output ports combined.
Op vrijdag 20 mei 2016 16:59:35 UTC+2 schreef Erik Simmler: > > Does anyone have a good pattern for handling multiple nested components > that need to communicate with JS via ports/subscriptions? > > I have a list of items, and I'm trying to allow any of these children to > send a message through a port and receive the result back via a > subscription. I have the outgoing port and incoming subscription wired up > and functioning (using `Sub.batch` similarly to > https://github.com/evancz/elm-architecture-tutorial/blob/master/nesting/4-gif-list.elm#L150), > > but any message I get back through the port from JS land is duplicated for > each child. > > Furthermore, I can't come up with a nice way to get them tagged and > directly properly without moving the ports up to the containing component > and "manually" wrapping/unwrapping the commands and messages, which seems > like an unfortunate level of coupling. > > In the elm-architecture-tutorial repo, the Gif component requests a new > url by returning a command created by `getRandomGif` ( > https://github.com/evancz/elm-architecture-tutorial/blob/master/nesting/Gif.elm#L53). > > In the second nesting example, the only relevant place that I can see any > mapping occurring is the usual `Cmd.map` at > https://github.com/evancz/elm-architecture-tutorial/blob/master/nesting/4-gif-list.elm#L93. > > Yet, when the `FetchSucceed` comes back, it is properly wrapped in a > `SubMsg Int` message. > > This seems to be exactly what I want, but I can't figure out how it works. > How I can replicate this effect on my own or am I just barking up the wrong > tree? Thanks! > -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
