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

  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/transformer.md.

All modules:

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard