PropertyDelegate

open class PropertyDelegate<R, T : Any>(proxy: Proxy, val interfaceName: InterfaceName, val propertyName: PropertyName, type: KSerializer<T>, module: SerializersModule, signature: TypeSignature) : ReadOnlyProperty<R, T>

A read-only Kotlin property delegate backed by a D-Bus property.

Reading the delegated property issues a D-Bus Get. The delegate also offers convenience accessors (getOrNull, await) and reactive observation of the property (changes, values, changesOrNull, valuesOrNull). Obtain one via Proxy.propDelegate.

The observation methods come in two families:

  • changes/changesOrNull emit change events only — nothing is emitted until the property changes after collection starts.

  • values/valuesOrNull emit the current value first, then all subsequent changes.

Each family has a throwing and a nullable variant: get, changes and values surface a missing/invalidated property as an exception or by dropping the event, while getOrNull, changesOrNull and valuesOrNull represent it as null.

Inheritors

Constructors

Link copied to clipboard
constructor(proxy: Proxy, interfaceName: InterfaceName, propertyName: PropertyName, type: KSerializer<T>, module: SerializersModule, signature: TypeSignature)

Properties

Link copied to clipboard

Interface that declares the property

Link copied to clipboard

Name of the property

Functions

Link copied to clipboard
suspend fun await(): T

Waits for the property to be present and returns the first value when it is. If the property is currently valid, then it is returned immediately.

Link copied to clipboard
fun changes(): Flow<T>

Produces a flow that observes the PropertiesChanged signal and emits the new value of this property each time it changes.

Link copied to clipboard
fun changesOrNull(): Flow<T?>

Like changes but also emits null whenever the property has been invalidated (i.e. it appears in the invalidatedProperties of a PropertiesChanged signal), instead of dropping the event.

Link copied to clipboard
fun get(): T

Gets the current value of the property.

Link copied to clipboard
fun getOrNull(): T?

Gets the current value of the property, however if the property doesn't currently exist (org.freedesktop.DBus.Error.InvalidArgs), returns null rather than throwing. Any other com.monkopedia.sdbus.SdbusException is still thrown.

Link copied to clipboard
open operator override fun getValue(thisRef: R, property: KProperty<*>): T
Link copied to clipboard
fun values(): Flow<T>

Produces a flow of all values of the property: the current value (from get) is emitted first when collection starts, followed by every subsequent change (from changes).

Link copied to clipboard
fun valuesOrNull(): Flow<T?>

Like values but null-safe: the current value (from getOrNull, null if the property doesn't currently exist) is emitted first when collection starts, followed by every subsequent change (from changesOrNull, which emits null on invalidation).