Promise

open external class Promise<out T>(executor: (resolve: (T) -> Unit, reject: (Throwable) -> Unit) -> Unit)(source)

Exposes the JavaScript Promise object to Kotlin.

Since Kotlin

1.1
external class Promise<out T : JsAny?>(executor: (resolve: (T) -> Unit, reject: (JsAny) -> Unit) -> Unit) : JsAny(source)

Exposes the JavaScript Promise object to Kotlin.

Since Kotlin

1.8

Constructors

Link copied to clipboard
constructor(executor: (resolve: (T) -> Unit, reject: (Throwable) -> Unit) -> Unit)
constructor(executor: (resolve: (T) -> Unit, reject: (JsAny) -> Unit) -> Unit)

Types

Link copied to clipboard
object Companion
Since Kotlin 1.1
object Companion
Since Kotlin 1.8

Functions

Link copied to clipboard
open fun <S> catch(onRejected: (Throwable) -> S): Promise<S>
Since Kotlin 1.1
fun <S : JsAny?> catch(onRejected: (JsAny) -> S): Promise<S>
Since Kotlin 1.8
Link copied to clipboard
open fun finally(onFinally: () -> Unit): Promise<T>
Since Kotlin 1.1
fun finally(onFinally: () -> Unit): Promise<T>
Since Kotlin 1.8
Link copied to clipboard
open fun <S> then(onFulfilled: (T) -> S?): Promise<S>
open fun <S> then(onFulfilled: (T) -> S?, onRejected: (Throwable) -> S?): Promise<S>
Since Kotlin 1.1
fun <S : JsAny?> then(onFulfilled: (T) -> S?): Promise<S>
fun <S : JsAny?> then(onFulfilled: (T) -> S?, onRejected: (JsAny) -> S?): Promise<S>
Since Kotlin 1.8
Link copied to clipboard
inline fun <T, S> Promise<Promise<T>>.then(noinline onFulfilled: (T) -> S?): Promise<S>
inline fun <T, S> Promise<Promise<T>>.then(noinline onFulfilled: (T) -> S?, noinline onRejected: (Throwable) -> S?): Promise<S>
Since Kotlin 1.1
Link copied to clipboard

For a Dynamic value caught in JS, returns the corresponding Throwable if it was thrown from Kotlin, or null otherwise.

Since Kotlin 1.8
Link copied to clipboard
fun <T : JsAny> JsAny.unsafeCast(): T

Cast JsAny to other Js type without runtime check

Since Kotlin 1.8