From 33215e5c31b55617edf0d95e47e9e720fe4b9dd6 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Thu, 24 Oct 2019 19:54:16 +0200 Subject: Allow suspending functions for SelectRemote and TabulatorRemote components. --- .../main/kotlin/pl/treksoft/kvision/form/select/SelectRemote.kt | 4 ++-- .../kotlin/pl/treksoft/kvision/form/select/SelectRemoteInput.kt | 4 ++-- .../main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt | 8 ++++---- .../main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt | 8 ++++---- .../main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt | 8 ++++---- .../main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt | 8 ++++---- .../main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt | 8 ++++---- .../main/kotlin/pl/treksoft/kvision/tabulator/TabulatorRemote.kt | 4 ++-- 8 files changed, 26 insertions(+), 26 deletions(-) (limited to 'kvision-modules') diff --git a/kvision-modules/kvision-bootstrap-select-remote/src/main/kotlin/pl/treksoft/kvision/form/select/SelectRemote.kt b/kvision-modules/kvision-bootstrap-select-remote/src/main/kotlin/pl/treksoft/kvision/form/select/SelectRemote.kt index 1cabb5dd..74cb3694 100644 --- a/kvision-modules/kvision-bootstrap-select-remote/src/main/kotlin/pl/treksoft/kvision/form/select/SelectRemote.kt +++ b/kvision-modules/kvision-bootstrap-select-remote/src/main/kotlin/pl/treksoft/kvision/form/select/SelectRemote.kt @@ -51,7 +51,7 @@ import pl.treksoft.kvision.utils.SnOn open class SelectRemote( value: String? = null, serviceManager: KVServiceManager, - function: T.(String?, String?, String?) -> List, + function: suspend T.(String?, String?, String?) -> List, stateFunction: (() -> String)? = null, name: String? = null, multiple: Boolean = false, @@ -258,7 +258,7 @@ open class SelectRemote( fun Container.selectRemote( value: String? = null, serviceManager: KVServiceManager, - function: T.(String?, String?, String?) -> List, stateFunction: (() -> String)? = null, + function: suspend T.(String?, String?, String?) -> List, stateFunction: (() -> String)? = null, name: String? = null, multiple: Boolean = false, ajaxOptions: AjaxOptions? = null, label: String? = null, rich: Boolean = false, init: (SelectRemote.() -> Unit)? = null ): SelectRemote { diff --git a/kvision-modules/kvision-bootstrap-select-remote/src/main/kotlin/pl/treksoft/kvision/form/select/SelectRemoteInput.kt b/kvision-modules/kvision-bootstrap-select-remote/src/main/kotlin/pl/treksoft/kvision/form/select/SelectRemoteInput.kt index e44c63d5..af3f1a52 100644 --- a/kvision-modules/kvision-bootstrap-select-remote/src/main/kotlin/pl/treksoft/kvision/form/select/SelectRemoteInput.kt +++ b/kvision-modules/kvision-bootstrap-select-remote/src/main/kotlin/pl/treksoft/kvision/form/select/SelectRemoteInput.kt @@ -54,7 +54,7 @@ external fun decodeURIComponent(encodedURI: String): String open class SelectRemoteInput( value: String? = null, serviceManager: KVServiceManager, - function: T.(String?, String?, String?) -> List, + function: suspend T.(String?, String?, String?) -> List, stateFunction: (() -> String)? = null, multiple: Boolean = false, ajaxOptions: AjaxOptions? = null, @@ -127,7 +127,7 @@ open class SelectRemoteInput( fun Container.selectRemoteInput( value: String? = null, serviceManager: KVServiceManager, - function: T.(String?, String?, String?) -> List, + function: suspend T.(String?, String?, String?) -> List, stateFunction: (() -> String)? = null, multiple: Boolean = false, ajaxOptions: AjaxOptions? = null, diff --git a/kvision-modules/kvision-common-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-common-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt index 9f07948d..3d0b5115 100644 --- a/kvision-modules/kvision-common-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt +++ b/kvision-modules/kvision-common-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt @@ -114,16 +114,16 @@ expect open class KVServiceManager(serviceClass: KClass) { * Binds a given function of the receiver as a select options source * @param function a function of the receiver */ - protected fun bind( - function: T.(String?, String?, String?) -> List + protected fun bindSelectRemote( + function: suspend T.(String?, String?, String?) -> List ) /** * Binds a given function of the receiver as a tabulator component source * @param function a function of the receiver */ - protected inline fun bind( - noinline function: T.(Int?, Int?, List?, List?) -> RemoteData + protected inline fun bindTabulatorRemote( + noinline function: suspend T.(Int?, Int?, List?, List?) -> RemoteData ) /** diff --git a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt index dd54a979..5c7cac7f 100644 --- a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt +++ b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt @@ -132,8 +132,8 @@ actual open class KVServiceManager actual constructor(serviceClass: KCl * Binds a given function of the receiver as a select options source * @param function a function of the receiver */ - protected actual fun bind( - function: T.(String?, String?, String?) -> List + protected actual fun bindSelectRemote( + function: suspend T.(String?, String?, String?) -> List ) { val routeDef = "route${this::class.simpleName}${counter++}" calls[function.toString().replace("\\s".toRegex(), "")] = Pair("/kv/$routeDef", HttpMethod.POST) @@ -143,8 +143,8 @@ actual open class KVServiceManager actual constructor(serviceClass: KCl * Binds a given function of the receiver as a tabulator component source * @param function a function of the receiver */ - protected actual inline fun bind( - noinline function: T.(Int?, Int?, List?, List?) -> RemoteData + protected actual inline fun bindTabulatorRemote( + noinline function: suspend T.(Int?, Int?, List?, List?) -> RemoteData ) { val routeDef = "route${this::class.simpleName}${counter++}" calls[function.toString().replace("\\s".toRegex(), "")] = Pair("/kv/$routeDef", HttpMethod.POST) diff --git a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt index fd95be3e..6bb28059 100644 --- a/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt +++ b/kvision-modules/kvision-server-jooby/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt @@ -416,8 +416,8 @@ actual open class KVServiceManager actual constructor(val serviceClass: * @param function a function of the receiver */ @Suppress("TooGenericExceptionCaught") - protected actual fun bind( - function: T.(String?, String?, String?) -> List + protected actual fun bindSelectRemote( + function: suspend T.(String?, String?, String?) -> List ) { val routeDef = "route${this::class.simpleName}${counter++}" routes.add { @@ -455,8 +455,8 @@ actual open class KVServiceManager actual constructor(val serviceClass: * @param function a function of the receiver */ @Suppress("TooGenericExceptionCaught") - protected actual inline fun bind( - noinline function: T.(Int?, Int?, List?, List?) -> RemoteData + protected actual inline fun bindTabulatorRemote( + noinline function: suspend T.(Int?, Int?, List?, List?) -> RemoteData ) { val routeDef = "route${this::class.simpleName}${counter++}" routes.add { diff --git a/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt index e550be9c..4d19e301 100644 --- a/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt +++ b/kvision-modules/kvision-server-ktor/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt @@ -442,8 +442,8 @@ actual open class KVServiceManager actual constructor(val serviceClass: * @param function a function of the receiver */ @Suppress("TooGenericExceptionCaught") - protected actual fun bind( - function: T.(String?, String?, String?) -> List + protected actual fun bindSelectRemote( + function: suspend T.(String?, String?, String?) -> List ) { val routeDef = "route${this::class.simpleName}${counter++}" addRoute(HttpMethod.POST, "/kv/$routeDef") { @@ -486,8 +486,8 @@ actual open class KVServiceManager actual constructor(val serviceClass: * @param function a function of the receiver */ @Suppress("TooGenericExceptionCaught") - protected actual inline fun bind( - noinline function: T.(Int?, Int?, List?, List?) -> RemoteData + protected actual inline fun bindTabulatorRemote( + noinline function: suspend T.(Int?, Int?, List?, List?) -> RemoteData ) { val routeDef = "route${this::class.simpleName}${counter++}" addRoute(HttpMethod.POST, "/kv/$routeDef") { diff --git a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt index 25ad52ed..295ec8fb 100644 --- a/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt +++ b/kvision-modules/kvision-server-spring-boot/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt @@ -506,8 +506,8 @@ actual open class KVServiceManager actual constructor(val serviceClass: * @param function a function of the receiver */ @Suppress("TooGenericExceptionCaught") - protected actual fun bind( - function: T.(String?, String?, String?) -> List + protected actual fun bindSelectRemote( + function: suspend T.(String?, String?, String?) -> List ) { val routeDef = "route${this::class.simpleName}${counter++}" addRoute(HttpMethod.POST, "/kv/$routeDef") { req, ctx -> @@ -557,8 +557,8 @@ actual open class KVServiceManager actual constructor(val serviceClass: * @param function a function of the receiver */ @Suppress("TooGenericExceptionCaught") - protected actual inline fun bind( - noinline function: T.(Int?, Int?, List?, List?) -> RemoteData + protected actual inline fun bindTabulatorRemote( + noinline function: suspend T.(Int?, Int?, List?, List?) -> RemoteData ) { val routeDef = "route${this::class.simpleName}${counter++}" addRoute(HttpMethod.POST, "/kv/$routeDef") { req, ctx -> diff --git a/kvision-modules/kvision-tabulator-remote/src/main/kotlin/pl/treksoft/kvision/tabulator/TabulatorRemote.kt b/kvision-modules/kvision-tabulator-remote/src/main/kotlin/pl/treksoft/kvision/tabulator/TabulatorRemote.kt index d37f3ea9..33cf44b3 100644 --- a/kvision-modules/kvision-tabulator-remote/src/main/kotlin/pl/treksoft/kvision/tabulator/TabulatorRemote.kt +++ b/kvision-modules/kvision-tabulator-remote/src/main/kotlin/pl/treksoft/kvision/tabulator/TabulatorRemote.kt @@ -49,7 +49,7 @@ import pl.treksoft.kvision.utils.JSON @UseExperimental(ImplicitReflectionSerializer::class) open class TabulatorRemote( serviceManager: KVServiceManager, - function: E.(Int?, Int?, List?, List?) -> RemoteData, + function: suspend E.(Int?, Int?, List?, List?) -> RemoteData, options: TabulatorOptions = TabulatorOptions(), types: Set = setOf(), classes: Set = setOf() @@ -98,7 +98,7 @@ open class TabulatorRemote( */ fun Container.tabulatorRemote( serviceManager: KVServiceManager, - function: E.(Int?, Int?, List?, List?) -> RemoteData, + function: suspend E.(Int?, Int?, List?, List?) -> RemoteData, options: TabulatorOptions = TabulatorOptions(), types: Set = setOf(), classes: Set = setOf(), -- cgit