W3cubDocs

/Kotlin

Promise

Platform and version requirements: JS (1.1)
open class Promise<out T>

Exposes the JavaScript Promise object to Kotlin.

Constructors

Platform and version requirements: JS (1.1)

<init>

Exposes the JavaScript Promise object to Kotlin.

Promise(
    executor: (resolve: (T) -> Unit, reject: (Throwable) -> Unit) -> Unit)

Functions

Platform and version requirements: JS (1.1)

catch

open fun <S> catch(onRejected: (Throwable) -> S): Promise<S>
Platform and version requirements: JS (1.1)

then

open fun <S> then(onFulfilled: ((T) -> S)?): Promise<S>
open fun <S> then(
    onFulfilled: ((T) -> S)?, 
    onRejected: ((Throwable) -> S)?
): Promise<S>

Companion Object Functions

Platform and version requirements: JS (1.1)

all

fun <S> all(
    promise: Array<out Promise<S>>
): Promise<Array<out S>>
Platform and version requirements: JS (1.1)

race

fun <S> race(promise: Array<out Promise<S>>): Promise<S>
Platform and version requirements: JS (1.1)

reject

fun reject(e: Throwable): Promise<Nothing>
Platform and version requirements: JS (1.1)

resolve

fun <S> resolve(e: S): Promise<S>
fun <S> resolve(e: Promise<S>): Promise<S>

Extension Functions

Platform and version requirements: JS (1.1)

then

fun <T, S> Promise<Promise<T>>.then(
    onFulfilled: ((T) -> S)?
): Promise<S>
fun <T, S> Promise<Promise<T>>.then(
    onFulfilled: ((T) -> S)?, 
    onRejected: ((Throwable) -> S)?
): Promise<S>

© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.js/-promise/index.html