Is there a way to do applicationHelper/includeUDF specific for a module? I have been looking around for a solution to this but couldn’t find anything. My modules will be acting like separate sub-apps and will have slightly different logic between them.
No there isn’t. Modules are, for the most part, assimilated into the parent app. This means any application helpers that a module contributes apply to the entire app. If you have more than one module with application helpers who include functions of the same name, you’d probably get a compilation error about defining the same UDF twice.
If you want to make your UDF behave differently based on what event is being run, that information should be available in the request context.
Yes good advice. I did suspect that if I had ‘function1()’ as method in the application’s applicationHelper file and then had ‘function1()’ as method in my Modules applicationHelper I would run into problems. I should be ok though if I have ‘function1()’ in moduleA’s applicationHelper and ‘function1()’ in moduleB’'s applicationHelper, yes? At least it seems to work that way.
There is only a single setting for application helpers in a Coldbox app. It does not track helpers individually for each module. When a module is loaded, your helpers are added to the global list. You’re likely not noticing the issue because you’re incorrectly overwriting the entire array instead of appending.