diff options
author | Robert Jaros <rjaros@finn.pl> | 2019-10-24 19:54:16 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2019-10-24 19:54:16 +0200 |
commit | 33215e5c31b55617edf0d95e47e9e720fe4b9dd6 (patch) | |
tree | 11e90cbfaacf37dbe1ce4fd8ce3eb28d02dd4867 /kvision-modules | |
parent | 69958b1a08f46aecd6ceda54780f362019150052 (diff) | |
download | kvision-33215e5c31b55617edf0d95e47e9e720fe4b9dd6.tar.gz kvision-33215e5c31b55617edf0d95e47e9e720fe4b9dd6.tar.bz2 kvision-33215e5c31b55617edf0d95e47e9e720fe4b9dd6.zip |
Allow suspending functions for SelectRemote and TabulatorRemote components.
Diffstat (limited to 'kvision-modules')
8 files changed, 26 insertions, 26 deletions
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<T : Any>( value: String? = null, serviceManager: KVServiceManager<T>, - function: T.(String?, String?, String?) -> List<RemoteOption>, + function: suspend T.(String?, String?, String?) -> List<RemoteOption>, stateFunction: (() -> String)? = null, name: String? = null, multiple: Boolean = false, @@ -258,7 +258,7 @@ open class SelectRemote<T : Any>( fun <T : Any> Container.selectRemote( value: String? = null, serviceManager: KVServiceManager<T>, - function: T.(String?, String?, String?) -> List<RemoteOption>, stateFunction: (() -> String)? = null, + function: suspend T.(String?, String?, String?) -> List<RemoteOption>, stateFunction: (() -> String)? = null, name: String? = null, multiple: Boolean = false, ajaxOptions: AjaxOptions? = null, label: String? = null, rich: Boolean = false, init: (SelectRemote<T>.() -> Unit)? = null ): SelectRemote<T> { 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<T : Any>( value: String? = null, serviceManager: KVServiceManager<T>, - function: T.(String?, String?, String?) -> List<RemoteOption>, + function: suspend T.(String?, String?, String?) -> List<RemoteOption>, stateFunction: (() -> String)? = null, multiple: Boolean = false, ajaxOptions: AjaxOptions? = null, @@ -127,7 +127,7 @@ open class SelectRemoteInput<T : Any>( fun <T : Any> Container.selectRemoteInput( value: String? = null, serviceManager: KVServiceManager<T>, - function: T.(String?, String?, String?) -> List<RemoteOption>, + function: suspend T.(String?, String?, String?) -> List<RemoteOption>, 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<T : Any>(serviceClass: KClass<T>) { * 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<RemoteOption> + protected fun bindSelectRemote( + function: suspend T.(String?, String?, String?) -> List<RemoteOption> ) /** * Binds a given function of the receiver as a tabulator component source * @param function a function of the receiver */ - protected inline fun <reified RET> bind( - noinline function: T.(Int?, Int?, List<RemoteFilter>?, List<RemoteSorter>?) -> RemoteData<RET> + protected inline fun <reified RET> bindTabulatorRemote( + noinline function: suspend T.(Int?, Int?, List<RemoteFilter>?, List<RemoteSorter>?) -> RemoteData<RET> ) /** 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<T : Any> 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<RemoteOption> + protected actual fun bindSelectRemote( + function: suspend T.(String?, String?, String?) -> List<RemoteOption> ) { 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<T : Any> 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 <reified RET> bind( - noinline function: T.(Int?, Int?, List<RemoteFilter>?, List<RemoteSorter>?) -> RemoteData<RET> + protected actual inline fun <reified RET> bindTabulatorRemote( + noinline function: suspend T.(Int?, Int?, List<RemoteFilter>?, List<RemoteSorter>?) -> RemoteData<RET> ) { 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<T : Any> actual constructor(val serviceClass: * @param function a function of the receiver */ @Suppress("TooGenericExceptionCaught") - protected actual fun bind( - function: T.(String?, String?, String?) -> List<RemoteOption> + protected actual fun bindSelectRemote( + function: suspend T.(String?, String?, String?) -> List<RemoteOption> ) { val routeDef = "route${this::class.simpleName}${counter++}" routes.add { @@ -455,8 +455,8 @@ actual open class KVServiceManager<T : Any> actual constructor(val serviceClass: * @param function a function of the receiver */ @Suppress("TooGenericExceptionCaught") - protected actual inline fun <reified RET> bind( - noinline function: T.(Int?, Int?, List<RemoteFilter>?, List<RemoteSorter>?) -> RemoteData<RET> + protected actual inline fun <reified RET> bindTabulatorRemote( + noinline function: suspend T.(Int?, Int?, List<RemoteFilter>?, List<RemoteSorter>?) -> RemoteData<RET> ) { 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<T : Any> actual constructor(val serviceClass: * @param function a function of the receiver */ @Suppress("TooGenericExceptionCaught") - protected actual fun bind( - function: T.(String?, String?, String?) -> List<RemoteOption> + protected actual fun bindSelectRemote( + function: suspend T.(String?, String?, String?) -> List<RemoteOption> ) { val routeDef = "route${this::class.simpleName}${counter++}" addRoute(HttpMethod.POST, "/kv/$routeDef") { @@ -486,8 +486,8 @@ actual open class KVServiceManager<T : Any> actual constructor(val serviceClass: * @param function a function of the receiver */ @Suppress("TooGenericExceptionCaught") - protected actual inline fun <reified RET> bind( - noinline function: T.(Int?, Int?, List<RemoteFilter>?, List<RemoteSorter>?) -> RemoteData<RET> + protected actual inline fun <reified RET> bindTabulatorRemote( + noinline function: suspend T.(Int?, Int?, List<RemoteFilter>?, List<RemoteSorter>?) -> RemoteData<RET> ) { 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<T : Any> actual constructor(val serviceClass: * @param function a function of the receiver */ @Suppress("TooGenericExceptionCaught") - protected actual fun bind( - function: T.(String?, String?, String?) -> List<RemoteOption> + protected actual fun bindSelectRemote( + function: suspend T.(String?, String?, String?) -> List<RemoteOption> ) { val routeDef = "route${this::class.simpleName}${counter++}" addRoute(HttpMethod.POST, "/kv/$routeDef") { req, ctx -> @@ -557,8 +557,8 @@ actual open class KVServiceManager<T : Any> actual constructor(val serviceClass: * @param function a function of the receiver */ @Suppress("TooGenericExceptionCaught") - protected actual inline fun <reified RET> bind( - noinline function: T.(Int?, Int?, List<RemoteFilter>?, List<RemoteSorter>?) -> RemoteData<RET> + protected actual inline fun <reified RET> bindTabulatorRemote( + noinline function: suspend T.(Int?, Int?, List<RemoteFilter>?, List<RemoteSorter>?) -> RemoteData<RET> ) { 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<T : Any, E : Any>( serviceManager: KVServiceManager<E>, - function: E.(Int?, Int?, List<RemoteFilter>?, List<RemoteSorter>?) -> RemoteData<T>, + function: suspend E.(Int?, Int?, List<RemoteFilter>?, List<RemoteSorter>?) -> RemoteData<T>, options: TabulatorOptions<T> = TabulatorOptions(), types: Set<TableType> = setOf(), classes: Set<String> = setOf() @@ -98,7 +98,7 @@ open class TabulatorRemote<T : Any, E : Any>( */ fun <T : Any, E : Any> Container.tabulatorRemote( serviceManager: KVServiceManager<E>, - function: E.(Int?, Int?, List<RemoteFilter>?, List<RemoteSorter>?) -> RemoteData<T>, + function: suspend E.(Int?, Int?, List<RemoteFilter>?, List<RemoteSorter>?) -> RemoteData<T>, options: TabulatorOptions<T> = TabulatorOptions(), types: Set<TableType> = setOf(), classes: Set<String> = setOf(), |