MutableSite

interface MutableSite<in T, out M> : Site<M>

A mutable version of Site, which allows the insertion of the events T through its event method. Each MutableSite is associated with a globally unique SiteIdentifier, which will be used when yielding events.

Parameters

T

the type of the events managed by this Site.

M

the type of the underlying aggregated model for this Site.

Functions

Link copied to clipboard
abstract suspend fun <R> event(block: EventScope<T>.(M) -> R): R

Creates some new events, that are generated in the EventScope. This function returns an arbitrary user-provided value once the events have been successfully added to the underlying MutableSite.

Link copied to clipboard
abstract fun receive(incoming: Flow<Message.Outgoing>): Flow<Message.Incoming>

Sends some I as a response to an incoming of O.

Link copied to clipboard
abstract fun send(incoming: Flow<Message.Incoming>): Flow<Message.Outgoing>

Sends some O as a response to an incoming of I.

Properties

Link copied to clipboard
abstract val identifier: SiteIdentifier

The globally unique SiteIdentifier for this Site.

Link copied to clipboard
abstract val value: Flow<M>

Returns the current value.

Extensions

Link copied to clipboard
fun <T, M> MutableSite<T, M>.flowOn(context: CoroutineContext): MutableSite<T, M>

Transforms a MutableSite by making it flow on a specific dispatcher. The same CoroutineContext will be used in both directions for the communicating Flows.

Link copied to clipboard
fun <T, M1, M2> MutableSite<T, M1>.map(f: (M1) -> M2): MutableSite<T, M2>

Transforms a MutableSite to make it return a different kind of model. This may be particularly useful when creating abstractions backed by a MutableSite that should not expose some implementation details.