Protocol
JSBridgedClass
public protocol JSBridgedClass: JSBridgedType
Conform to this protocol when your Swift class wraps a JavaScript class.
Relationships
Conforms To
JSBridgedType
Use this protocol when your type has no single JavaScript class. For example, a union type of multiple classes or primitive values.
Types Conforming to JSBridgedClass
JSArray
A wrapper around the JavaScript
Array
class that exposes its properties in a type-safe and Swifty way.JSDate
A wrapper around the JavaScript
Date
class that exposes its properties in a type-safe way. This doesn't 100% match the JS API, for examplegetMonth
/setMonth
etc accessor methods are converted to properties, but the rest of it matches in the naming. Parts of the JavaScriptDate
API that are not consistent across browsers and JS implementations are not exposed in a type-safe manner, you should access the underlyingjsObject
property if you need those.JSError
A wrapper around the JavaScript
Error
class that exposes its properties in a type-safe way.JSPromise
A wrapper around the JavaScript
Promise
classJSTypedArray
A wrapper around all JavaScript
TypedArray
classes that exposes their properties in a type-safe way.
Default Implementations
init?(from:)
init?(from value: JSValue)
init?(from:)
init?(from object: JSObject)
Requirements
jsObject
var jsObject: JSObject
The JavaScript object wrapped by this instance.
You may assume that jsObject instanceof Self.constructor == true
init(unsafelyWrapping:)
init(unsafelyWrapping jsObject: JSObject)
Create an instance wrapping the given JavaScript object.
You may assume that jsObject instanceof Self.constructor