Skip to content

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

  1. Declare a feature's signals, effects and state classes, and a Contracts object listing its handles.
  2. Build its transformer with transformer(Contracts) { }: state(...), on<T> handlers, answer and handle.
  3. In a ViewModel, create a router with viewModelScope.router(name, transformers…). Call global() if it must reach other routers.
  4. Send input with router.process(signal), and observe state with router.state(handle).
  5. Test the transformer with transformer.test { send(...); awaitState(...) }.

Deprecated

  • transmission-viewmodel (RouterViewModel): use viewModelScope.router(...) in a plain ViewModel.
  • Classic transformer API: Transformer subclasses with configure { }, onSignal and onEffect, Contract factories, dataHolder, TransmissionRouter { }, and the TransmissionTest harness.
  • Checkpoints: pauseOn, validate and Contract.checkpoint() will be removed in 3.0; use awaitSignal.

The classic API keeps working in 2.x. Its reference is under Classic API.