GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Add `JSRemote<T>` for owner-thread `JSObject` access · Issue #704 · swiftwasm/JavaScriptKit Closed DescriptionMotivation
This is the right default for safety, but it leaves a gap for cases where Swift code wants to keep a stable reference to a JavaScript object while interacting with it from another isolation domain. Today the only public cross-thread escape hatch is We need a small, explicit abstraction for that use case: a sendable handle that can be passed across threads, while only exposing the underlying OverviewThis proposal introduces The initial scope is intentionally narrow:
The key design constraints are:
API Design (draft)The first public shape would be: @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) public struct JSRemote<T>: @unchecked Sendable @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension JSRemote where T == JSObject { public init(_ object: JSObject) public func withJSObject<R: Sendable>( _ body: (JSObject) -> R ) async -> R } Usage: let remote = JSRemote(document) let title = await remote.withJSObject { document in document.title.string ?? "" } Semantics:
Reacted by Max Desiatov, Andrew Luey and Adin ActivityMetadataMetadataAssigneesLabelsNo labels TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |