Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Commit

Permalink
make KVar mappings support nullables
Browse files Browse the repository at this point in the history
  • Loading branch information
sanity committed Jul 14, 2019
1 parent dac93d0 commit 8b6a594
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.3.40'
id 'org.jetbrains.kotlin.jvm' version '1.3.41'
id 'maven'
id 'org.jetbrains.dokka' version '0.9.17'
id 'com.github.johnrengelman.shadow' version '5.0.0'
Expand All @@ -13,7 +13,7 @@ ext {
}

group 'io.kweb'
version '0.4.24'
version '0.4.25'

repositories {
mavenCentral()
Expand Down
12 changes: 5 additions & 7 deletions src/main/kotlin/io/kweb/Kweb.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,21 @@ import io.ktor.features.*
import io.ktor.http.*
import io.ktor.http.cio.websocket.Frame.Text
import io.ktor.http.cio.websocket.readText
import io.ktor.request.*
import io.ktor.request.uri
import io.ktor.response.respondText
import io.ktor.routing.*
import io.ktor.server.engine.EngineAPI
import io.ktor.server.engine.applicationEngineEnvironment
import io.ktor.server.engine.embeddedServer
import io.ktor.server.engine.*
import io.ktor.server.jetty.*
import io.ktor.websocket.*
import io.kweb.client.Server2ClientMessage.Instruction
import io.kweb.browserConnection.KwebClientConnection
import io.kweb.browserConnection.KwebClientConnection.Caching
import io.kweb.client.*
import io.kweb.client.Server2ClientMessage.Instruction
import io.kweb.plugins.KwebPlugin
import kotlinx.coroutines.*
import kotlinx.coroutines.time.delay
import org.apache.commons.io.IOUtils
import java.io.*
import java.io.Closeable
import java.time.*
import java.util.*
import java.util.concurrent.*
Expand Down Expand Up @@ -189,7 +187,7 @@ class Kweb @EngineAPI constructor(val port: Int,
RemoteClientState(id = kwebSessionId, clientConnection = Caching())
}

val httpRequestInfo = HttpRequestInfo(call.request)
val httpRequestInfo = io.kweb.client.HttpRequestInfo(call.request)

try {
if (debug) {
Expand Down
8 changes: 3 additions & 5 deletions src/main/kotlin/io/kweb/state/KVar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package io.kweb.state

import mu.KotlinLogging
import kotlin.properties.Delegates
import kotlin.reflect.KProperty0
import kotlin.reflect.KProperty1
import kotlin.reflect.full.instanceParameter
import kotlin.reflect.full.memberFunctions
import kotlin.reflect.full.*

private val logger = KotlinLogging.logger {}

Expand All @@ -22,7 +20,7 @@ class KVar<T : Any?>(initialValue: T) : KVal<T>(initialValue) {
}
}

fun <O : Any> map(reversableFunction: ReversableFunction<T, O>): KVar<O> {
fun <O : Any?> map(reversableFunction: ReversableFunction<T, O>): KVar<O> {
if (isClosed) {
logger.warn("Mapping an already closed KVar", IllegalStateException())
}
Expand All @@ -47,7 +45,7 @@ class KVar<T : Any?>(initialValue: T) : KVal<T>(initialValue) {

}

inline fun <O : Any, reified T : Any> KVar<T>.property(property: KProperty1<T, O>): KVar<O> {
inline fun <O : Any?, reified T : Any?> KVar<T>.property(property: KProperty1<T, O>): KVar<O> {
return this.map(object : ReversableFunction<T, O>("prop: ${property.name}") {

private val kClass = T::class
Expand Down

0 comments on commit 8b6a594

Please sign in to comment.