Hope you all have a great time these past holidays…
Question: what is the beast approach to share data between modules?
Now I’m just injecting handlers from one module to another and call its methods, but I guess this is not a good approach, since handlers constantly change according to its module parent needs and this can break communication between other modules.
When you say “handlers”, do you mean “handler” or “models”?
There’s no need to inject a handler and call its methods directly. Use runEvent() for that.
There’s nothing wrong with using the models of another module AS LONG AS those models are meant to be a usable API. It’s your app, so this is up to you.
Outside of registering interceptors, settings, etc, i would say the primary way a module offers its “services” to another module or the rest of the application is by it’s models (which may literally be services). In ColdBox 4, just put them somewhere in the “models” folder and WireBox will create mappings for you so it’s easy and seamless.
/modules/foo/models/bar.cfc becomes available to the rest of the application as “bar@foo”.
Sometimes modules can be used to create black boxes of standalone functionality. Other times, they can be deeply intertwined with each other and simply separated to help break up the code into workable chunks-- possibly even managed by different teams.
ColdBox Platform Evangelist
Ortus Solutions, Corp
ColdBox Platform: http://www.coldbox.org