emscripten-core / emscripten-core/emscripten
Feature request: Support "once" property when registering callbacks
- 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
Assessment
This issue has not been assessed yet.