File tree 1 file changed +5
-6
lines changed
1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change 3
3
public protocol JSBridgedType : JSValueCodable , CustomStringConvertible {
4
4
var objectRef : JSObject { get }
5
5
init ? ( objectRef: JSObject )
6
- static func canDecode( _ object: JSObject ) -> Bool
7
6
}
8
7
9
8
extension JSBridgedType {
10
9
public static func construct( from value: JSValue ) -> Self ? {
11
- guard let object = value. object, canDecode ( object) else {
12
- return nil
13
- }
10
+ guard let object = value. object else { return nil }
14
11
return Self . init ( objectRef: object)
15
12
}
16
13
@@ -26,11 +23,13 @@ extension JSBridgedType {
26
23
27
24
public protocol JSBridgedClass : JSBridgedType {
28
25
static var classRef : JSFunction { get }
26
+ init ( withCompatibleObject objectRef: JSObject )
29
27
}
30
28
31
29
extension JSBridgedClass {
32
- public static func canDecode( from jsValue: JSValue ) -> Bool {
33
- jsValue. isInstanceOf ( Self . classRef)
30
+ public init ? ( objectRef: JSObject ) {
31
+ guard objectRef. isInstanceOf ( Self . classRef) else { return nil }
32
+ self . init ( withCompatibleObject: objectRef)
34
33
}
35
34
}
36
35
You can’t perform that action at this time.
0 commit comments