aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules/kvision-cordova/src/main/kotlin/pl
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2019-06-07 20:03:50 +0200
committerRobert Jaros <rjaros@finn.pl>2019-06-07 20:03:50 +0200
commit5f1681474cdfb7a140adc8e93414e488b335d29e (patch)
tree2a4b2e26e65f39f291434cf83a1876d41f99c56c /kvision-modules/kvision-cordova/src/main/kotlin/pl
parentc73905e037608c76b08e4a3327fc53fe72a96622 (diff)
downloadkvision-5f1681474cdfb7a140adc8e93414e488b335d29e.tar.gz
kvision-5f1681474cdfb7a140adc8e93414e488b335d29e.tar.bz2
kvision-5f1681474cdfb7a140adc8e93414e488b335d29e.zip
New getStatus() function for cordova battery api.
Diffstat (limited to 'kvision-modules/kvision-cordova/src/main/kotlin/pl')
-rw-r--r--kvision-modules/kvision-cordova/src/main/kotlin/pl/treksoft/kvision/cordova/Battery.kt13
1 files changed, 13 insertions, 0 deletions
diff --git a/kvision-modules/kvision-cordova/src/main/kotlin/pl/treksoft/kvision/cordova/Battery.kt b/kvision-modules/kvision-cordova/src/main/kotlin/pl/treksoft/kvision/cordova/Battery.kt
index 84a7eb2e..656a519a 100644
--- a/kvision-modules/kvision-cordova/src/main/kotlin/pl/treksoft/kvision/cordova/Battery.kt
+++ b/kvision-modules/kvision-cordova/src/main/kotlin/pl/treksoft/kvision/cordova/Battery.kt
@@ -23,6 +23,8 @@
package pl.treksoft.kvision.cordova
import kotlin.browser.window
+import kotlin.coroutines.resume
+import kotlin.coroutines.suspendCoroutine
/**
* Battery status.
@@ -57,4 +59,15 @@ object Battery {
}, false)
}
}
+
+ /**
+ * Get battery status.
+ */
+ suspend fun getStatus(): BatteryStatus {
+ return suspendCoroutine { continuation ->
+ addStatusListener(Battery.BatteryEvent.BATTERY_STATUS) { status ->
+ continuation.resume(status)
+ }
+ }
+ }
}