From 9b8ecf0e0d3c6573711dc29bcd2b1b22db720540 Mon Sep 17 00:00:00 2001 From: Max Cahill Date: Fri, 23 Aug 2024 22:42:51 +1000 Subject: [PATCH] modified pubsub:subscribe_once to return the wrapper function created so it's possible to unsub if needed --- pubsub.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pubsub.lua b/pubsub.lua index ca04b6f..6645048 100644 --- a/pubsub.lua +++ b/pubsub.lua @@ -96,6 +96,7 @@ function pubsub:subscribe(event, callback) end --subscribe to an event, automatically unsubscribe once called +--return the function that can be used to unsubscribe early if needed function pubsub:subscribe_once(event, callback) local f local called = false @@ -107,6 +108,7 @@ function pubsub:subscribe_once(event, callback) end end self:subscribe(event, f) + return f end --unsubscribe from an event