|
| 1 | +# Module kotlinx-coroutines-core-js |
| 2 | + |
| 3 | +Core primitives to work with coroutines on Kotlin/JS. |
| 4 | + |
| 5 | +Coroutine builder functions: |
| 6 | + |
| 7 | +| **Name** | **Result** | **Scope** | **Description** |
| 8 | +| ------------- | ------------- | ---------------- | --------------- |
| 9 | +| [launch] | [Job] | [CoroutineScope] | Launches coroutine that does not have any result |
| 10 | +| [async] | [Deferred] | [CoroutineScope] | Returns a single value with the future result |
| 11 | +| [runBlocking] | `T` | [CoroutineScope] | Blocks the event loop while the coroutine runs |
| 12 | + |
| 13 | +Coroutine dispatchers implementing [CoroutineDispatcher]: |
| 14 | + |
| 15 | +| **Name** | **Description** |
| 16 | +| --------------------------- | --------------- |
| 17 | +| [DefaultDispatcher] | Posts execution to JS event loop |
| 18 | +| [Unconfined] | Does not confine coroutine execution in any way |
| 19 | + |
| 20 | +More context elements: |
| 21 | + |
| 22 | +| **Name** | **Description** |
| 23 | +| --------------------------- | --------------- |
| 24 | +| [NonCancellable] | A non-cancelable job that is always active |
| 25 | +| [CoroutineExceptionHandler] | Handler for uncaught exception |
| 26 | + |
| 27 | +Top-level suspending functions: |
| 28 | + |
| 29 | +| **Name** | **Description** |
| 30 | +| ------------------- | --------------- |
| 31 | +| [delay] | Non-blocking sleep |
| 32 | +| [yield] | Yields thread in single-threaded dispatchers |
| 33 | +| [withContext] | Switches to a different context |
| 34 | +| [withTimeout] | Set execution time-limit with exception on timeout |
| 35 | +| [withTimeoutOrNull] | Set execution time-limit will null result on timeout |
| 36 | + |
| 37 | +Cancellation support for user-defined suspending functions is available with [suspendCancellableCoroutine] |
| 38 | +helper function. [NonCancellable] job object is provided to suppress cancellation with |
| 39 | +`run(NonCancellable) {...}` block of code. |
| 40 | + |
| 41 | +# Package kotlinx.coroutines.experimental |
| 42 | + |
| 43 | +General-purpose coroutine builders, contexts, and helper functions. |
| 44 | + |
| 45 | +<!--- MODULE kotlinx-coroutines-core-js --> |
| 46 | +<!--- INDEX kotlinx.coroutines.experimental --> |
| 47 | +[launch]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/launch.html |
| 48 | +[Job]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-job/index.html |
| 49 | +[CoroutineScope]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-coroutine-scope/index.html |
| 50 | +[async]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/async.html |
| 51 | +[Deferred]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-deferred/index.html |
| 52 | +[runBlocking]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/run-blocking.html |
| 53 | +[CoroutineDispatcher]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-coroutine-dispatcher/index.html |
| 54 | +[DefaultDispatcher]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-default-dispatcher.html |
| 55 | +[CommonPool]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-common-pool/index.html |
| 56 | +[newSingleThreadContext]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/new-single-thread-context.html |
| 57 | +[newFixedThreadPoolContext]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/new-fixed-thread-pool-context.html |
| 58 | +[java.util.concurrent.Executor.asCoroutineDispatcher]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/java.util.concurrent.-executor/as-coroutine-dispatcher.html |
| 59 | +[Unconfined]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-unconfined/index.html |
| 60 | +[NonCancellable]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-non-cancellable/index.html |
| 61 | +[CoroutineExceptionHandler]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-coroutine-exception-handler/index.html |
| 62 | +[delay]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/delay.html |
| 63 | +[yield]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/yield.html |
| 64 | +[withContext]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/with-context.html |
| 65 | +[withTimeout]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/with-timeout.html |
| 66 | +[withTimeoutOrNull]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/with-timeout-or-null.html |
| 67 | +[Job.join]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-job/join.html |
| 68 | +[Job.onJoin]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-job/on-join.html |
| 69 | +[Job.isCompleted]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-job/is-completed.html |
| 70 | +[Deferred.await]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-deferred/await.html |
| 71 | +[Deferred.onAwait]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/-deferred/on-await.html |
| 72 | +[suspendCancellableCoroutine]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/suspend-cancellable-coroutine.html |
| 73 | +[newCoroutineContext]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/new-coroutine-context.html |
| 74 | +<!--- END --> |
0 commit comments