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 |
Contracts with state(initial), query<R>(), queryWith<A, R>(), command(), commandWith<A>() |
A feature's public state, queries and commands, as named handles | Contracts |
transformer(name) { }, transformer(contracts) { } |
Builds a transformer | Transformer |
state(handle) |
Transformer-owned state, published on every change | State |
on<T> { }, accepts<T>(), awaitSignal<T>() |
Handles messages and waits for the next one | Handlers |
answer(query) { }, handle(command) { } |
Serves a feature's queries and commands | Contracts |
emit, publish(effect), publish(effect, to = …), Cart.summary(), Cart.clear() |
What a handler can do | Transformer Communication |
onError { }, onCleared { } |
Error and lifecycle callbacks | Transformer |
scope.router(name, transformers…) { }, global() |
A router that lives as long as its scope, optionally joined to other routers | Router |
router.process(message), router.state(handle), router.stream(handle) |
Sends input and observes output, wherever the state's owner is | Router |
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.
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 API.