diff options
author | Robert Jaros <rjaros@finn.pl> | 2019-01-23 11:00:47 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2019-01-23 11:00:47 +0100 |
commit | cd5885383ac25750bfcf11d19f9bed34d7a4c7f5 (patch) | |
tree | 1aa2e0656a36ac6d9938c052317aaa8b66f3cea0 | |
parent | 48153da7cd97c57a60ca1032d19cdec0714c4c04 (diff) | |
download | kvision-cd5885383ac25750bfcf11d19f9bed34d7a4c7f5.tar.gz kvision-cd5885383ac25750bfcf11d19f9bed34d7a4c7f5.tar.bz2 kvision-cd5885383ac25750bfcf11d19f9bed34d7a4c7f5.zip |
Handlebars.js dependency upgrade + one helper extension function.
-rw-r--r-- | kvision-modules/kvision-handlebars/build.gradle | 4 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/utils/JSON.kt | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/kvision-modules/kvision-handlebars/build.gradle b/kvision-modules/kvision-handlebars/build.gradle index 918ed5a7..3a374298 100644 --- a/kvision-modules/kvision-handlebars/build.gradle +++ b/kvision-modules/kvision-handlebars/build.gradle @@ -3,8 +3,8 @@ apply from: "../shared.gradle" kotlinFrontend { npm { - dependency("handlebars", "4.0.11") - dependency("handlebars-loader", "1.7.0") + dependency("handlebars", "4.0.12") + dependency("handlebars-loader", "1.7.1") } } diff --git a/src/main/kotlin/pl/treksoft/kvision/utils/JSON.kt b/src/main/kotlin/pl/treksoft/kvision/utils/JSON.kt index e47351ac..a826d343 100644 --- a/src/main/kotlin/pl/treksoft/kvision/utils/JSON.kt +++ b/src/main/kotlin/pl/treksoft/kvision/utils/JSON.kt @@ -21,8 +21,10 @@ */ package pl.treksoft.kvision.utils +import kotlinx.serialization.ImplicitReflectionSerializer import kotlinx.serialization.context.SimpleModule import kotlinx.serialization.json.JSON +import kotlinx.serialization.serializer import pl.treksoft.kvision.types.DateSerializer import kotlin.js.Date @@ -36,4 +38,11 @@ object JSON { install(SimpleModule(Date::class, DateSerializer)) } + /** + * An extension function to convert Serializable object to JS dynamic object + */ + @UseExperimental(ImplicitReflectionSerializer::class) + inline fun <reified T : Any> T.toObj(): Any { + return kotlin.js.JSON.parse(plain.stringify(T::class.serializer(), this)) + } } |