Skip to content

Commit fca7080

Browse files
committed
Add JSAbstractBridgedType
1 parent 751a3d7 commit fca7080

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Sources/JavaScriptKit/JSValueConvertible.swift

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import _CJavaScriptKit
22

3-
public protocol JSBridgedType: JSValueCodable, CustomStringConvertible {
4-
static var classRef: JSFunctionRef { get }
5-
3+
// Use this protocol when your type has no single JavaScript class.
4+
// For example, a union type of multiple classes.
5+
public protocol JSAbstractBridgedType: JSValueCodable, CustomStringConvertible {
66
var objectRef: JSObjectRef { get }
77
init(objectRef: JSObjectRef)
88
}
99

10-
extension JSBridgedType {
10+
extension JSAbstractBridgedType {
1111
public var description: String {
1212
return objectRef.toString!().fromJSValue()
1313
}
1414
}
1515

16+
public protocol JSBridgedType: JSAbstractBridgedType {
17+
static var classRef: JSFunctionRef { get }
18+
}
19+
1620
public protocol JSValueEncodable {
1721
func jsValue() -> JSValue
1822
}

0 commit comments

Comments
 (0)