Doc #4
@ -36,7 +36,7 @@ interface Device: Closeable {
|
||||
/**
|
||||
* Remove all listeners belonging to the specified owner
|
||||
*/
|
||||
fun removeListener(owner: Any?)
|
||||
fun removeListeners(owner: Any?)
|
||||
|
||||
/**
|
||||
* Get the value of the property or throw error if property in not defined.
|
||||
|
@ -18,6 +18,6 @@ suspend fun DeviceHub.setProperty(deviceName: String, propertyName: String, valu
|
||||
.setProperty(propertyName, value)
|
||||
}
|
||||
|
||||
suspend fun DeviceHub.request(deviceName: String, command: String, argument: MetaItem<*>?): MetaItem<*>? =
|
||||
suspend fun DeviceHub.call(deviceName: String, command: String, argument: MetaItem<*>?): MetaItem<*>? =
|
||||
(getDevice(deviceName) ?: error("Device with name $deviceName not found in the hub"))
|
||||
.call(command, argument)
|
@ -19,7 +19,7 @@ abstract class DeviceBase : Device {
|
||||
listeners.add(owner to listener)
|
||||
}
|
||||
|
||||
override fun removeListener(owner: Any?) {
|
||||
override fun removeListeners(owner: Any?) {
|
||||
listeners.removeAll { it.first == owner }
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,6 @@ suspend fun Device.flowValues(): Flow<Pair<String, MetaItem<*>>> = callbackFlow
|
||||
}
|
||||
registerListener(listener)
|
||||
awaitClose {
|
||||
removeListener(listener)
|
||||
removeListeners(listener)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user