Trouble with nested submodules and ports

In my application, with a layout inspired of the spa-example app 1, I have some pages I would like to split up even more, and hence create submodules of that page (nested submodules). I use ports to create graphs and charts with echart 2, and while I can call them from the a page that is a submodule of Main, calls to the ports from a nested submodule do not seem to be registered.

E.g. I have a page “Overview”, where the user can switch between different “tabs” or subpages that has different graphs or tables. Each of these I have put in its own module. So I can call the port and render a graph directly from the Overview-module, but not from one of its children.

As I am pretty new with ports, I assume I have misunderstood or overlooked something, but I haven’t manage to figure out what. Is there a special way to reference a port from a nested submodule?

Ports will return Cmds, which must be returned from update (or init). If you don’t return the Cmd, it won’t actually do anything. My first thought is the Cmd is getting created but then thrown away.

We can be a lot more specific if you link your code!

When i call it from Overview, the Cmd is registered in the Main’s update. But when I call if from the subpage, it isn’t registered in the parent’s update.

No special way but you do have to make sure that the command returned by the submodule’s update gets passed all the way to the runtime.

When troubles like these come up, I usually discover that I forgot to return the command from the next-level-up update.

1 Like

Yeah, I belive the error is related to that. I’m not sure exactly where, since every other command works, just not the one related to the port.

Have you got some code we can look at?

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.