I’m trying to create a component that can be re-used in multiple applications across my company, however I’m having trouble figuring out how to handle link generation.
For the sake of this example, let’s say I have 2 applications -
Bravo. A standalone component of application
Alpha may be used in either
Bravo. When the component generates anchors/links to resources in
Alpha, it needs to be somehow aware of what application it’s currently in since in the
Alpha case, the component should likely use the
linkTo helper in order to transition state within the application. When the component is used in
Bravo, it seems like an absolute URL would need to be generated since not only do I not have my route definitions included, the application is on an entirely different domain.
To complicate this a bit further, we have several different stages that an application can be deployed to ( i.e. devel, qa, production ). The link generation should be aware of the environment so that if
Bravo is in devel or local development, then the links generated by the
Alpha component should point to the development version of
My initial thought on how to accomplish this is to create a service that you may configure during app bootstrapping and would provide link generation utilities, however that doesn’t help in the case where I feel like we should be using
Alpha Component in the
Alpha Application ).
Has anyone else encountered similar scenarios, and how would you suggest tackling something like this?