emscripten-core / emscripten-core/emscripten

Feature request: Support "once" property when registering callbacks

Open
#23,140 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

For actions such as `emscripten_set_click_callback`, it would be really useful to support the `once` property in some way: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#once (similar to how the `capture` property is exposed via the `useCapture` parameter).

One use case would be in the Audio Worklets example laid out at https://emscripten.org/docs/api_reference/wasm_audio_worklets.html - here the click callback is needed for the first click ever only, to unpause the audio, and should ideally be unset after that.

In many cases this could also serve as an alternative to https://github.com/emscripten-core/emscripten/issues/20983 ("Add a way to remove a single event listener").

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.