Skip to content

Commit

Permalink
Exposed ConnectionManager.removeConnection and better handling of `Ke…
Browse files Browse the repository at this point in the history
…y.get`
  • Loading branch information
darkfrog26 committed Nov 19, 2019
1 parent abd8186 commit 538a2ba
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/jvm/src/main/scala/io/youi/app/ConnectionManager.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ConnectionManager[C <: Connection](app: ServerConnectedApplication[C]) {
_connections @= (connection :: _connections()).distinct
}

private def removeConnection(connection: C): Unit = synchronized {
def removeConnection(connection: C): Unit = synchronized {
_connections @= _connections.filterNot(_ eq connection)
connection.disconnect()
connection.queue.dispose()
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import sbtcrossproject.CrossType

name := "youi"
organization in ThisBuild := "io.youi"
version in ThisBuild := "0.12.7"
version in ThisBuild := "0.12.8-SNAPSHOT"
scalaVersion in ThisBuild := "2.13.1"
crossScalaVersions in ThisBuild := List("2.13.1", "2.12.10")
resolvers in ThisBuild ++= Seq(
Expand Down
8 changes: 6 additions & 2 deletions ui/shared/src/main/scala/io/youi/Key.scala
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,13 @@ object Key {
map += key.value -> key
}

def get(value: String): Option[Key] = map.get(value)
def get(value: => String): Option[Key] = try {
map.get(value)
} catch {
case t: Throwable => None
}

def apply(value: String): Key = get(value).getOrElse(throw new RuntimeException(s"Unable to find Key for '$value'."))
def apply(value: => String): Key = get(value).getOrElse(Key.Unidentified)
}

case class KeyType private(name: String)
Expand Down

0 comments on commit 538a2ba

Please sign in to comment.