All Downloads are FREE. Search and download functionalities are using the official Maven repository.

japgolly.scalajs.react.extra.internal.LazyVar.scala Maven / Gradle / Ivy

There is a newer version: 3.0.0-beta6
Show newest version
package japgolly.scalajs.react.extra.internal

final class LazyVar[A](initArg: () => A) {

  // Don't prevent GC of initArg or waste mem propagating the ref
  private[this] var init = initArg

  private[this] var value: A = _

  def get(): A = {
    if (init ne null)
      set(init())
    value
  }

  def set(a: A): Unit = {
    value = a
    init = null
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy