API Overview
Transmission is a Kotlin Multiplatform library for asynchronous communication between business-logic components. This page lists the public API by module. Every entry links to the page that covers it.
Core Module: transmission
| API | What it is | Page |
|---|---|---|
Transmission.Signal, Transmission.Effect, Transmission.Data |
Messages from outside, messages between transformers, and output to observers | transmissions.md |
Contracts with state(initial), query<R>(), queryWith<A, R>(), command(), commandWith<A>() |
A feature's public state, queries and commands, as named handles | contracts.md |
transformer(name) { }, transformer(contracts) { } |
Builds a transformer | transformer.md |
state(handle) |
Transformer-owned state, published on every change | dataholder.md |
on<T> { }, accepts<T>(), awaitSignal<T>() |
Handles messages and waits for the next one | handlers.md |
answer(query) { }, handle(command) { } |
Serves a feature's queries and commands | contracts.md |
emit, publish(effect), publish(effect, to = …), Cart.summary(), Cart.clear() |
What a handler can do | transformer_communication.md |
onError { }, onCleared { } |
Error and lifecycle callbacks | transformer.md |
scope.router(name, transformers…) { }, global() |
A router that lives as long as its scope, optionally joined to other routers | router.md |
router.process(message), router.state(handle), router.stream(handle) |
Sends input and observes output, wherever the state's owner is | router.md |
Testing Module: transmission-test
| API | What it is |
|---|---|
transformer.test(dispatcher) { } |
Runs a test against one transformer |
fake(query), fake(state, value), fake(command) |
Stand-ins for the transformer's neighbours |
send, awaitState, awaitData<T>(), awaitEffect<T>(), expectNoEffects(), settle() |
Drives the test and checks its output |
See testing.md.
Typical Flow
-
Declare a feature's signals, effects and state classes, and a
Contractsobject listing its handles. -
Build its transformer with
transformer(Contracts) { }:state(...),on<T>handlers,answerandhandle. -
In a ViewModel, create a router with
viewModelScope.router(name, transformers…). Callglobal()if it must reach other routers. -
Send input with
router.process(signal), and observe state withrouter.state(handle). -
Test the transformer with
transformer.test { send(...); awaitState(...) }.
Deprecated
-
transmission-viewmodel(RouterViewModel): useviewModelScope.router(...)in a plainViewModel. -
Classic transformer API:
Transformersubclasses withconfigure { },onSignalandonEffect,Contractfactories,dataHolder,TransmissionRouter { }, and theTransmissionTestharness. -
Checkpoints:
pauseOn,validateandContract.checkpoint()will be removed in 3.0; useawaitSignal.
The classic API keeps working in 2.x. Its reference is under classic/transformer.md.