In umbrella, need a reference to another app

I have an umbrella with a master app where all others are defined as deps. I can call modules in other apps from this masterapp using the other appname as prefix. But how should I do it the other way around? Should I send references to the dependent apps? How can I do that? Right now I want to do something like this from a dependency, but I don’t have a reference to BpmServer (master app):

BpmModeler.Endpoint.broadcast("workflows:0",
                              "refreshWorkflowList",
                              %{}
                             )
BpmServer.Endpoint.broadcast("workflows:0",
                              "refreshWorkflowList",
                              %{}
                             )

I guess that means your dependency also has the master app as a dependency (ie. you’re having a circular dependency)?

One naive way to solve this is to add the BpmServer as a dependency of the BpmModeler (or whatever it is you’re calling it from). However, that way it would tightly couple the two apps. I don’t know if it will introduce design problems.

Or, you might pass BpmServer.Endpoint module as a :master_endpoint config for your deps or something, and then use it with apply/3 like so:

apply(master_endpoint, :broadcast, ["workflows:0", "refreshWorkflowList", %{}])

Again, I don’t know if it’s a good idea in your case, YMMV :slight_smile:

1 Like

Thanks Bobby. The coupling is indeed a problem. Maybe I can solve this with PubSub (http://yos.io/2016/06/15/pub-sub-in-elixir/).