do I have to read the source for each object to learns its methods?
Yes, you will have to read the source code to see what methods are available.
The question is in the title. Basically is there a hook fired after the hook
static:app.load has been processed by all plugins. But let me give you some context what I'm trying to achieve, perhaps my design is flawed.
I'm currently in the process of writing a Prometheus exporter plugin so I can plug some forum metrics into my overall server monitoring system. But I also would like that other plugins could use my plugin to provide further metrics. So I was considering to fire two hooks from this Prometheus plugin.
static:nodebb-plugin-prometheus.init- Will fire after initialization passing in the Prometheus client to setup the metrics that should be collected.
action:nodebb-plugin-prometheus.metrics- Will fire repeatably when it is time to update the metrics. Can be configured by the user.
Obviously I only want to fire
static:nodebb-plugin-prometheus.init after all plugins have initialized or else they might run into some kind of racing conditions. They couldn't be sure if they would be initialized whenever
static:nodebb-plugin-prometheus.init is called. Thus why I would like to fire this hook after initialization was done.
Now perhaps my idea to use hooks is the wrong approach? Should plugins interact between each other differently? Or is there another problem you see?
Theoretically, I think you can ensure your prometheus client is fired last by moving the hook priority down in the ACP plugins ordering menu (although I think that only works with templates )
Attach a "priority" value to the hook? https://github.com/NodeBB/NodeBB/blob/master/src/plugins/hooks.js#L29
I wrote that code sometime in 2013, so I don't actually remember whether a higher priority is later, or a lower priority Try it out and report back?
A higher priority would be later in execution. The hooks are sorted here.
But the priority is mostly ignored for static and action hooks. Since
async.each is used to fire them.
async.each works in parallel. Meaning that they will be started in the order of the priority but you have no guarantee that the previous hooks have completed when your hook is called.