Skip to content

Commit

Permalink
Fix to allow LateInitProperty as QueryParameter
Browse files Browse the repository at this point in the history
  • Loading branch information
iHoonter committed Nov 18, 2024
1 parent 51641eb commit 5328ffe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package com.lightningkite.kiteui.navigation
import com.lightningkite.kiteui.decodeURIComponent
import com.lightningkite.kiteui.encodeURIComponent
import com.lightningkite.kiteui.reactive.ImmediateWritable
import com.lightningkite.kiteui.reactive.ImmediateWriteOnly
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable
Expand Down Expand Up @@ -43,8 +44,8 @@ fun <T> Properties.decodeFromStringMap(serializer: KSerializer<T>, key: String,
if(filtered.isEmpty()) return null
return decodeFromStringMap(Wrapper.serializer(serializer), filtered).value
}
inline fun <reified T> Properties.decodeFromStringMap(key: String, source: Map<String, String>, into: ImmediateWritable<T>) {
decodeFromStringMap(serializersModule.serializer<T>(), key, source)?.let { into.value = it }
inline fun <reified T> Properties.decodeFromStringMap(key: String, source: Map<String, String>, into: ImmediateWriteOnly<T>) {
decodeFromStringMap(serializersModule.serializer<T>(), key, source)?.let { into.setImmediate(it) }
}
inline fun <reified T> Properties.encodeToStringMap(value: T, key: String, out: MutableMap<String, String>) = encodeToStringMap(UrlProperties.serializersModule.serializer<T>(), value, key, out)
inline fun <reified T> Properties.decodeFromStringMap(key: String, source: Map<String, String>): T? = decodeFromStringMap(UrlProperties.serializersModule.serializer<T>(), key, source)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ class Property<T>(startValue: T) : ImmediateWritable<T>, BaseImmediateReadable<T
}
}

class LateInitProperty<T>() : Writable<T>, BaseReadable<T>() {
class LateInitProperty<T>() : Writable<T>, ImmediateWriteOnly<T>, BaseReadable<T>() {
var value: T
get() = state.get()
set(value) {
state = ReadableState(value)
}

override suspend infix fun set(value: T) {
override fun setImmediate(value: T) {
this.value = value
}

Expand Down

0 comments on commit 5328ffe

Please sign in to comment.