We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
.get{Option,OrThrow}
SetOnceVar
1 parent 8d8916d commit 891bd9dCopy full SHA for 891bd9d
utils/shared/src/main/scala/japgolly/microlibs/utils/SetOnceVar.scala
@@ -13,9 +13,18 @@ final class SetOnceVar[A] {
13
a
14
}
15
16
+
17
+ def getOption(): Option[A] =
18
+ synchronized(instance)
19
20
+ def getOrThrow(): A =
21
+ getOrThrow("SetOnceVar not yet set.")
22
23
+ def getOrThrow(errMsg: => String): A =
24
+ getOption().getOrElse(throw new RuntimeException(errMsg))
25
26
27
object SetOnceVar {
28
def apply[A]: SetOnceVar[A] =
29
new SetOnceVar
-}
30
+}
0 commit comments