moduleapi: Rename :once() to :on_ready() for clarity
authorMatthew Wild <mwild1@gmail.com>
Thu, 30 Nov 2023 10:07:53 +0000
changeset 13364 6037b7a2131c
parent 13363 1796370091d4
child 13365 e20949a10118
moduleapi: Rename :once() to :on_ready() for clarity 'Once' is ambiguous - once per what? on_ready() executes its parameter when the module is loaded *and* the server has finished starting.
core/moduleapi.lua
--- a/core/moduleapi.lua	Thu Nov 30 09:47:00 2023 +0000
+++ b/core/moduleapi.lua	Thu Nov 30 10:07:53 2023 +0000
@@ -781,8 +781,14 @@
 end
 
 -- Execute a function, once, but only after startup is complete
-function api:once(f) --luacheck: ignore 212/self
+function api:on_ready(f) --luacheck: ignore 212/self
 	return prosody.started:next(f);
 end
 
+-- COMPAT w/post 0.12 trunk
+function api:once(f)
+	self:log("warn", "This module uses deprecated module:once() - switch to module:on_ready() or (better) expose function module.ready()");
+	return self:on_ready(f);
+end
+
 return api;