Skip to content

Release v15#19

Merged
Insality merged 29 commits intomainfrom
develop
Mar 2, 2026
Merged

Release v15#19
Insality merged 29 commits intomainfrom
develop

Conversation

@Insality
Copy link
Copy Markdown
Owner

@Insality Insality commented Feb 27, 2026

  • subscribe_once: Added event:subscribe_once, events.subscribe_once, queue:subscribe_once, and queues.subscribe_once to subscribe a handler for a single invocation; the handler is automatically unsubscribed after the first call.
  • Unsubscribe during trigger: Calling unsubscribe from 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.
  • Fix when callback_context for subscription can't be false
  • Event as callback: Support for callback_context when subscribing an event to another event (e.g. event_2:subscribe(event_1, "any additional data")).
  • Unsubscribe event from event: Fixed unsubscribing one event from another so the correct subscription is found and removed.
  • Documentation and API pages updates.

@Insality Insality self-assigned this Feb 27, 2026
Copilot AI review requested due to automatic review settings February 27, 2026 23:15
@Insality Insality added the enhancement New feature or request label Feb 27, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 once method to event, events, queue, and queues modules (with tests and API docs for each).
  • Implemented safe deferred unsubscription using a _trigger_depth counter and a [5] delete flag so that calling unsubscribe inside a callback no longer skips remaining callbacks in the current trigger.
  • Fixed subscribe/unsubscribe/is_subscribed for event-as-callback with a custom context by introducing subscribe_event, unsubscribe_event, and is_subscribed_event helper 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.

Comment thread event/event.lua Outdated
Comment thread event/queue.lua Outdated
Comment thread api/queue_api.md Outdated
Comment thread event/event.lua Outdated
Comment thread event/event.lua Outdated
Comment thread event/event.lua Outdated
Comment thread event/event.lua Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread test/test_event.lua Outdated
Comment thread event/queue.lua Outdated
Comment thread event/queue.lua
Comment thread event/event.lua
Comment thread event/event.lua Outdated
Comment thread test/test_event.lua Outdated
Comment thread event/queues.lua
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread event/queues.lua
Comment thread event/queues.lua Outdated
Comment thread api/queues_api.md
Comment thread event/event.lua Outdated
Comment thread event/event.lua
Comment thread event/queue.lua Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread event/event.lua
Comment thread event/queue.lua
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread event/event.lua Outdated
Comment thread event/queue.lua
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread test/test_event_mode.lua
Comment thread test/test_event.lua Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_next uses 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.

Comment thread event/events.lua
Comment thread event/event.lua
Comment thread event/event.lua Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread event/queues.lua
Comment thread api/events_api.md
@Insality Insality merged commit b00cedb into main Mar 2, 2026
7 checks passed
@Insality Insality mentioned this pull request Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants