@@ -46,7 +46,7 @@ public final class JSPromise: JSBridgedClass {
46
46
/** Creates a new `JSPromise` instance from a given `resolver` closure. `resolver` takes
47
47
two closure that your code should call to either resolve or reject this `JSPromise` instance.
48
48
*/
49
- public convenience init ( resolver: @escaping ( @escaping ( Result < JSValue , JSValue > ) -> ( ) ) -> ( ) ) {
49
+ public convenience init ( resolver: @escaping ( @escaping ( Result < JSValueConvertible , JSValueConvertible > ) -> ( ) ) -> ( ) ) {
50
50
let closure = JSOneshotClosure { arguments in
51
51
// The arguments are always coming from the `Promise` constructor, so we should be
52
52
// safe to assume their type here
@@ -66,18 +66,18 @@ public final class JSPromise: JSBridgedClass {
66
66
self . init ( unsafelyWrapping: Self . constructor. new ( closure) )
67
67
}
68
68
69
- public static func resolve( _ value: JSValue ) -> JSPromise {
69
+ public static func resolve( _ value: JSValueConvertible ) -> JSPromise {
70
70
self . init ( unsafelyWrapping: Self . constructor. resolve!( value) . object!)
71
71
}
72
72
73
- public static func reject( _ reason: JSValue ) -> JSPromise {
73
+ public static func reject( _ reason: JSValueConvertible ) -> JSPromise {
74
74
self . init ( unsafelyWrapping: Self . constructor. reject!( reason) . object!)
75
75
}
76
76
77
77
/** Schedules the `success` closure to be invoked on sucessful completion of `self`.
78
78
*/
79
79
@discardableResult
80
- public func then( success: @escaping ( JSValue ) -> JSValue ) -> JSPromise {
80
+ public func then( success: @escaping ( JSValue ) -> JSValueConvertible ) -> JSPromise {
81
81
let closure = JSOneshotClosure {
82
82
return success ( $0 [ 0 ] )
83
83
}
@@ -87,8 +87,8 @@ public final class JSPromise: JSBridgedClass {
87
87
/** Schedules the `success` closure to be invoked on sucessful completion of `self`.
88
88
*/
89
89
@discardableResult
90
- public func then( success: @escaping ( JSValue ) -> JSValue ,
91
- failure: @escaping ( JSValue ) -> JSValue ) -> JSPromise {
90
+ public func then( success: @escaping ( JSValue ) -> JSValueConvertible ,
91
+ failure: @escaping ( JSValue ) -> JSValueConvertible ) -> JSPromise {
92
92
let successClosure = JSOneshotClosure {
93
93
return success ( $0 [ 0 ] )
94
94
}
@@ -101,7 +101,7 @@ public final class JSPromise: JSBridgedClass {
101
101
/** Schedules the `failure` closure to be invoked on rejected completion of `self`.
102
102
*/
103
103
@discardableResult
104
- public func `catch`( failure: @escaping ( JSValue ) -> JSValue ) -> JSPromise {
104
+ public func `catch`( failure: @escaping ( JSValue ) -> JSValueConvertible ) -> JSPromise {
105
105
let closure = JSOneshotClosure {
106
106
return failure ( $0 [ 0 ] )
107
107
}
0 commit comments