Conversation
There was a problem hiding this comment.
Pull request overview
This PR releases v15 of the defold-event library, adding a once API to all four event/queue modules, implementing safe deferred unsubscription during trigger iteration, adding callback_context support for event-as-callback subscriptions, and fixing event-from-event unsubscription.
Changes:
- Added
oncemethod toevent,events,queue, andqueuesmodules (with tests and API docs for each). - Implemented safe deferred unsubscription using a
_trigger_depthcounter and a[5]delete flag so that callingunsubscribeinside a callback no longer skips remaining callbacks in the current trigger. - Fixed
subscribe/unsubscribe/is_subscribedfor event-as-callback with a custom context by introducingsubscribe_event,unsubscribe_event, andis_subscribed_eventhelper functions.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
event/event.lua |
Core changes: once method, event-as-callback helpers, _trigger_depth tracking, deferred cleanup loop |
event/events.lua |
Added events.once() thin wrapper |
event/queue.lua |
Added queue:once() wrapping handler in an inner event; added cleanup of empty handler events in _check_subscribers |
event/queues.lua |
Added queues.once() thin wrapper |
test/test_event.lua |
New tests for once, event-with-context subscribe/unsubscribe, unsubscribe-during-trigger |
test/test_events.lua |
New test for events.once |
test/test_queue.lua |
New tests for queue:once including duplicate and pre-unsubscribe cases |
test/test_queues.lua |
New test for queues.once |
api/event_api.md |
Added once API documentation |
api/events_api.md |
Added once API documentation |
api/queue_api.md |
Added once API documentation |
api/queues_api.md |
Added once API documentation |
api/api.md |
Added once to the API overview |
USE_CASES.md |
Added use-case section 8 for once |
README.md |
Updated size table and added v15 changelog entry |
game.project |
Version bumped from 14 to 15 |
.gitignore |
Added deployer_version_settings.ini |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 17 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 19 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 22 out of 23 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…e-trigger same event inside
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 22 out of 23 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 22 out of 23 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 24 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
event/queues.lua:117
- Indentation in
process_nextuses spaces while the rest of the file uses tabs, which makes the block stand out and can create noisy diffs going forward. Please align the indentation with the surrounding style.
function M.process_next(queue_id, event_handler, context)
if not M.queues[queue_id] then
return false
end
return M.queues[queue_id]:process_next(event_handler, context)
end
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 24 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
event:subscribe_once,events.subscribe_once,queue:subscribe_once, andqueues.subscribe_onceto subscribe a handler for a single invocation; the handler is automatically unsubscribed after the first call.unsubscribefrom inside a callback no longer breaks the current trigger iteration; removals are applied after the trigger finishes, so all callbacks in the current trigger still run.callback_contextfor subscription can't befalsecallback_contextwhen subscribing an event to another event (e.g.event_2:subscribe(event_1, "any additional data")).