From f82d804e1d0f87de825262b4f0dbe206218da930 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 30 Nov 2023 10:07:53 +0000 Subject: 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'core/moduleapi.lua') diff --git a/core/moduleapi.lua b/core/moduleapi.lua index 09776fc1..06aec5c2 100644 --- a/core/moduleapi.lua +++ b/core/moduleapi.lua @@ -781,8 +781,14 @@ function api:may(action, context, peek) 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; -- cgit v1.2.3