publish

fun <T : Any> publish(topic: Topic<T>, data: T)

Publishes a message to the given topic.

DO NOT pass mutable structures to data. Subscribers expect data to be thread-safe.

It is recommended to only pass deeply immutable structures as data to avoid such unexpected side effects.

Parameters

topic

the topic to which the message will be published.

data

the data to be published with the message.

Type Parameters

T

the type of data contained in the message.