René's URL Explorer Experiment


Title: Looking for API ideas: Typed closure handle for BridgeJS · Issue #541 · swiftwasm/JavaScriptKit · GitHub

Open Graph Title: Looking for API ideas: Typed closure handle for BridgeJS · Issue #541 · swiftwasm/JavaScriptKit

X Title: Looking for API ideas: Typed closure handle for BridgeJS · Issue #541 · swiftwasm/JavaScriptKit

Description: Summary BridgeJS needs a typed closure handle type that preserves object identity across the Swift/JS bridge. We're looking for community input on naming. Background JavaScriptKit already has JSClosure for untyped closures: let closure =...

Open Graph Description: Summary BridgeJS needs a typed closure handle type that preserves object identity across the Swift/JS bridge. We're looking for community input on naming. Background JavaScriptKit already has JSClo...

X Description: Summary BridgeJS needs a typed closure handle type that preserves object identity across the Swift/JS bridge. We're looking for community input on naming. Background JavaScriptKit already has J...

Opengraph URL: https://github.com/swiftwasm/JavaScriptKit/issues/541

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Looking for API ideas: Typed closure handle for BridgeJS","articleBody":"## Summary\n\nBridgeJS needs a typed closure handle type that preserves object identity across the Swift/JS bridge. We're looking for community input on naming.\n\n## Background\n\nJavaScriptKit already has `JSClosure` for untyped closures:\n\n```swift\nlet closure = JSClosure { args -\u003e JSValue in\n    // ...\n}\n```\n\nFor BridgeJS, we need a **typed** variant with a generic parameter for the function signature. This enables type-safe declarations like:\n\n```swift\n@JSFunction func addEventListener(_ type: String, _ listener: (MessageEvent) -\u003e Void)\n```\n\nThe typed closure handle is essential for APIs like `addEventListener`/`removeEventListener` that require stable object identity, passing the same closure reference to both calls.\n\n## Related issues\n\n- https://github.com/swiftwasm/JavaScriptKit/issues/536\n  - We need the explicit handle to allow manually releasing JS-passed closures \n- https://github.com/swiftwasm/JavaScriptKit/issues/540\n\n## Constraints\n\n1. Must coexist with `JSClosure`: we can't simply make `JSClosure\u003cT\u003e` generic (breaking change)\n2. Explicit conversion required: Swift doesn't support implicit conversion from closure literals, so users will write the type name frequently\n\n## Candidates\n\n### 1. Nested type: `JSClosure.Typed\u003cT\u003e`\n\n```swift\n@JSClass struct JSHTMLElement {\n    @JSFunction func addEventListener(_ type: String, _ listener: JSClosure.Typed\u003c(MessageEvent) -\u003e Void\u003e)\n    @JSFunction func removeEventListener(_ type: String, _ listener: JSClosure.Typed\u003c(MessageEvent) -\u003e Void\u003e)\n}\n\nlet handler = JSClosure.Typed\u003c(MessageEvent) -\u003e Void\u003e { event in\n    print(event.data)\n}\ndocument.addEventListener(\"load\", handler)\ndocument.removeEventListener(\"load\", handler)\n\n@JSFunction func requestAnimationFrame(_ callback: JSOneshotClosure.Typed\u003c(Double) -\u003e Void\u003e)\n\nrequestAnimationFrame(JSOneshotClosure.Typed { timestamp in\n  print(timestamp)\n})\n```\n\n- Clear relationship to `JSClosure`\n- Discoverable via autocomplete\n- Verbose (15 characters)\n\n\n### 2. `JSTypedClosure\u003cT\u003e`\n\n\n```swift\n@JSClass struct JSHTMLElement {\n    @JSFunction func addEventListener(_ type: String, _ listener: JSTypedClosure\u003c(MessageEvent) -\u003e Void\u003e)\n    @JSFunction func removeEventListener(_ type: String, _ listener: JSTypedClosure\u003c(MessageEvent) -\u003e Void\u003e)\n}\n\nlet handler = JSTypedClosure\u003c(MessageEvent) -\u003e Void\u003e { event in\n    print(event.data)\n}\ndocument.addEventListener(\"load\", handler)\ndocument.removeEventListener(\"load\", handler)\n\n@JSFunction func requestAnimationFrame(_ callback: JSTypedClosure\u003c(Double) -\u003e Void\u003e)\n\nrequestAnimationFrame(JSTypedClosure.oneshot { timestamp in\n  print(timestamp)\n})\n```\n\n### 3. `JSCallback\u003cT\u003e`\n\n\n```swift\n@JSClass struct JSHTMLElement {\n    @JSFunction func addEventListener(_ type: String, _ listener: JSCallback\u003c(MessageEvent) -\u003e Void\u003e)\n    @JSFunction func removeEventListener(_ type: String, _ listener: JSCallback\u003c(MessageEvent) -\u003e Void\u003e)\n}\n\nlet handler = JSCallback\u003c(MessageEvent) -\u003e Void\u003e { event in\n    print(event.data)\n}\ndocument.addEventListener(\"load\", handler)\ndocument.removeEventListener(\"load\", handler)\n\n@JSFunction func requestAnimationFrame(_ callback: JSCallback.Oneshot\u003c(Double) -\u003e Void\u003e)\n\nrequestAnimationFrame(JSCallback.Oneshot { timestamp in\n  print(timestamp)\n})\n```\n\n### 3. [Need your input]\n","author":{"url":"https://github.com/kateinoigakukun","@type":"Person","name":"kateinoigakukun"},"datePublished":"2026-01-28T11:45:43.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/541/JavaScriptKit/issues/541"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:57da3230-262f-71f2-6c9c-e22daef73293
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD4A0:15B875:2BE193:37F542:69800922
html-safe-noncedbfe37a6f9186e53a0367902af4a6ca0dcece18362296e87cfb7a089936a1f8c
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENEEwOjE1Qjg3NToyQkUxOTM6MzdGNTQyOjY5ODAwOTIyIiwidmlzaXRvcl9pZCI6IjkwOTIwMTI1ODA0MzE2OTYyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac728c837fb260fb86ebf0fb8f15780a6113366b46efc359953c29d990b3f0a116
hovercard-subject-tagissue:3865028795
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/swiftwasm/JavaScriptKit/541/issue_layout
twitter:imagehttps://opengraph.githubassets.com/99fa4002a5bce2c5d840ee8bfb130dfeb44d8b3c17774a7cc91cbf935365840a/swiftwasm/JavaScriptKit/issues/541
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/99fa4002a5bce2c5d840ee8bfb130dfeb44d8b3c17774a7cc91cbf935365840a/swiftwasm/JavaScriptKit/issues/541
og:image:altSummary BridgeJS needs a typed closure handle type that preserves object identity across the Swift/JS bridge. We're looking for community input on naming. Background JavaScriptKit already has JSClo...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamekateinoigakukun
hostnamegithub.com
expected-hostnamegithub.com
None60279d4097367e16897439d16d6bbe4180663db828c666eeed2656988ffe59f6
turbo-cache-controlno-preview
go-importgithub.com/swiftwasm/JavaScriptKit git https://github.com/swiftwasm/JavaScriptKit.git
octolytics-dimension-user_id49500752
octolytics-dimension-user_loginswiftwasm
octolytics-dimension-repository_id244832006
octolytics-dimension-repository_nwoswiftwasm/JavaScriptKit
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id244832006
octolytics-dimension-repository_network_root_nwoswiftwasm/JavaScriptKit
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release7c85641c598ad130c74f7bcc27f58575cac69551
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/swiftwasm/JavaScriptKit/issues/541#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fswiftwasm%2FJavaScriptKit%2Fissues%2F541
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fswiftwasm%2FJavaScriptKit%2Fissues%2F541
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=swiftwasm%2FJavaScriptKit
Reloadhttps://github.com/swiftwasm/JavaScriptKit/issues/541
Reloadhttps://github.com/swiftwasm/JavaScriptKit/issues/541
Reloadhttps://github.com/swiftwasm/JavaScriptKit/issues/541
swiftwasm https://github.com/swiftwasm
JavaScriptKithttps://github.com/swiftwasm/JavaScriptKit
Please reload this pagehttps://github.com/swiftwasm/JavaScriptKit/issues/541
Notifications https://github.com/login?return_to=%2Fswiftwasm%2FJavaScriptKit
Fork 62 https://github.com/login?return_to=%2Fswiftwasm%2FJavaScriptKit
Star 836 https://github.com/login?return_to=%2Fswiftwasm%2FJavaScriptKit
Code https://github.com/swiftwasm/JavaScriptKit
Issues 33 https://github.com/swiftwasm/JavaScriptKit/issues
Pull requests 9 https://github.com/swiftwasm/JavaScriptKit/pulls
Actions https://github.com/swiftwasm/JavaScriptKit/actions
Projects 0 https://github.com/swiftwasm/JavaScriptKit/projects
Security 0 https://github.com/swiftwasm/JavaScriptKit/security
Insights https://github.com/swiftwasm/JavaScriptKit/pulse
Code https://github.com/swiftwasm/JavaScriptKit
Issues https://github.com/swiftwasm/JavaScriptKit/issues
Pull requests https://github.com/swiftwasm/JavaScriptKit/pulls
Actions https://github.com/swiftwasm/JavaScriptKit/actions
Projects https://github.com/swiftwasm/JavaScriptKit/projects
Security https://github.com/swiftwasm/JavaScriptKit/security
Insights https://github.com/swiftwasm/JavaScriptKit/pulse
New issuehttps://github.com/login?return_to=https://github.com/swiftwasm/JavaScriptKit/issues/541
New issuehttps://github.com/login?return_to=https://github.com/swiftwasm/JavaScriptKit/issues/541
Looking for API ideas: Typed closure handle for BridgeJShttps://github.com/swiftwasm/JavaScriptKit/issues/541#top
https://github.com/kateinoigakukun
https://github.com/kateinoigakukun
kateinoigakukunhttps://github.com/kateinoigakukun
on Jan 28, 2026https://github.com/swiftwasm/JavaScriptKit/issues/541#issue-3865028795
[BridgeJS] Swift closures are leaked when we bring them to JS world #536https://github.com/swiftwasm/JavaScriptKit/issues/536
[BridgeJS] Provide a way to take a JSObject handle of Swift closure passed to JS #540https://github.com/swiftwasm/JavaScriptKit/issues/540
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.