KiteConfigIoWorkerExtension

The generated browser Web Worker helper, inside kiteConfig { web { ioWorker { ... } } }.

kiteConfig {
web {
ioWorker {
targets("js")
packageName = "com.acme.app.generated"
}
}
}

Opening this block turns generation on. KiteConfig then writes a kiteConfigOffload function into each listed target's source set, so the plain js target gets it in jsMain. The function runs one JavaScript job on a throwaway worker, waits for the answer, and terminates the worker.

This is a small browser helper, not Dispatchers.IO and not a cross-platform worker runtime. It needs the browser Worker, Blob, and object-URL APIs, so Node.js-only targets and wasmJs are unsupported. You also add kotlinx-coroutines-core yourself: KiteConfig never adds a dependency for you.

The helper executes raw JavaScript source as code. Only pass source you wrote and trust, never anything built from user-controlled data. The deployed Content Security Policy must allow Blob workers too, normally with worker-src blob:.

Before this compiles in your app

You mustBecause
name a browser target with targetsbrowser capability is never inferred
add kotlinx-coroutines-core yourselfthe generated code suspends, and KiteConfig adds no dependencies
allow worker-src blob: in your CSPthe worker is created from a Blob URL

What it is not

NotInstead
Dispatchers.IOone job, one throwaway worker, no pool
a cross-platform APIbrowser Kotlin/JS only
a typed transportstrings in, strings out

See also

for the enclosing block.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
abstract val packageName: Property<String>

Kotlin package of the generated helper, written as dot-separated identifiers such as com.acme.app.generated.

Link copied to clipboard
abstract val projects: ListProperty<String>

Exact Gradle project paths that receive the helper, absolute, such as ":shared" or ":apps:web". Each one must apply Kotlin Multiplatform.

Link copied to clipboard
abstract val targets: ListProperty<String>

Exact Kotlin/JS target names that run in a browser.

Functions

Link copied to clipboard
fun projects(vararg paths: String)

Adds one or more project paths to projects.

Link copied to clipboard
fun targets(vararg names: String)

Adds one or more browser target names to targets.