modulemanager: Allow modules to expose module.ready - to be called after init
authorMatthew Wild <mwild1@gmail.com>
Thu, 30 Nov 2023 10:09:47 +0000
changeset 13365 e20949a10118
parent 13364 6037b7a2131c
child 13366 11e66ad894f0
modulemanager: Allow modules to expose module.ready - to be called after init This is a shortcut for module:on_ready() which exposes the functionality in an idiomatic way consistent with module.load, module.unload, etc. module.ready runs when the module is loaded and the server has finished starting up.
core/modulemanager.lua
--- a/core/modulemanager.lua	Thu Nov 30 10:07:53 2023 +0000
+++ b/core/modulemanager.lua	Thu Nov 30 10:09:47 2023 +0000
@@ -293,6 +293,10 @@
 				ok, err = do_load_module(host, module_name);
 			end
 		end
+
+		if module_has_method(pluginenv, "ready") then
+			pluginenv.module:on_ready(pluginenv.module.ready);
+		end
 	end
 	if not ok then
 		modulemap[api_instance.host][module_name] = nil;