Some method renaming, fixes #3

This commit is contained in:
Peter Klimai 2020-06-11 19:34:21 +03:00
parent d6c58a9c7e
commit b23152ff79
4 changed files with 4 additions and 4 deletions

View File

@ -36,7 +36,7 @@ interface Device: Closeable {
/** /**
* Remove all listeners belonging to the specified owner * 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. * Get the value of the property or throw error if property in not defined.

View File

@ -18,6 +18,6 @@ suspend fun DeviceHub.setProperty(deviceName: String, propertyName: String, valu
.setProperty(propertyName, value) .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")) (getDevice(deviceName) ?: error("Device with name $deviceName not found in the hub"))
.call(command, argument) .call(command, argument)

View File

@ -19,7 +19,7 @@ abstract class DeviceBase : Device {
listeners.add(owner to listener) listeners.add(owner to listener)
} }
override fun removeListener(owner: Any?) { override fun removeListeners(owner: Any?) {
listeners.removeAll { it.first == owner } listeners.removeAll { it.first == owner }
} }

View File

@ -23,6 +23,6 @@ suspend fun Device.flowValues(): Flow<Pair<String, MetaItem<*>>> = callbackFlow
} }
registerListener(listener) registerListener(listener)
awaitClose { awaitClose {
removeListener(listener) removeListeners(listener)
} }
} }