202#203
Merged
Merged
Conversation
…one-shot callbacks
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This was referenced May 13, 2026
Closed
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the
cb.forget()leak pattern withClosure::once_into_jsin the 13 one-shot callback sites listed in #202. JS now owns the boxed closure and deallocates it after the first invocation (or the same accept-the-leak behaviour the crate already had if Telegram never fires the callback).Files touched
src/webapp/permissions.rs:request_write_access,request_emoji_status_access,set_emoji_status,open_invoice,download_file,read_text_from_clipboardsrc/webapp/navigation.rs:share_message,request_chat,check_home_screen_statussrc/webapp/dialogs.rs:show_confirm,show_popup,show_scan_qr_popupsrc/webapp/core.rs:invoke_custom_methodAPI impact
F: 'static + Fn(...)→F: 'static + FnOnce(...). Strict expansion — everyFn/FnMutalready implementsFnOnce, so existing call sites continue to compile. The bound now also accepts callbacks that move captured state out, which was previously rejected.Out of scope (kept as
forget()for sound reasons)src/dom/element.rs::ElementExt::on— multi-shot event listener (e.g.click,input); the closure must outlive the element.src/api/{accelerometer,gyroscope,device_orientation}.rsevent subscriptions — multi-shot sensor streams.#[cfg(test)]modules.Test plan
cargo check --all-targets --all-featurescargo test --lib --all-features -p telegram-webapp-sdk(21/21 native — existing tests already exercise the touched paths)cargo test --no-run --lib --all-features -p telegram-webapp-sdk(all wasm tests compile)cargo +nightly-2025-08-01 fmt --all -- --checkcargo +1.95 clippy --workspace --all-targets --all-features -- -D warningsreuse lint(139/139)