Var

object Var
Companion:
class
class Object
trait Matchable
class Any
Var.type

Type members

Classlikes

final implicit class VarModTuple[A](val tuple: (Var[A], A => A)) extends AnyVal
final implicit class VarTryModTuple[A](val tuple: (Var[A], Try[A] => Try[A])) extends AnyVal
final implicit class VarTryTuple[A](val tuple: (Var[A], Try[A])) extends AnyVal
final implicit class VarTuple[A](val tuple: (Var[A], A)) extends AnyVal

Value members

Concrete methods

def apply[A](initial: A): Var[A]
def fromTry[A](initial: Try[A]): Var[A]
def set(values: VarTuple[_]*): Unit

Set multiple Var values in the same Transaction Example usage: Var.set(var1 -> value1, var2 -> value2)

Set multiple Var values in the same Transaction Example usage: Var.set(var1 -> value1, var2 -> value2)

If input contains duplicate vars, reports an Airstream unhandled error. Airstream allows a maximum of one event per observable per transaction.

def setTry(values: VarTryTuple[_]*): Unit

Set multiple Var values in the same Transaction Example usage: Var.setTry(var1 -> Success(value1), var2 -> Failure(error2))

Set multiple Var values in the same Transaction Example usage: Var.setTry(var1 -> Success(value1), var2 -> Failure(error2))

If input contains duplicate vars, reports an Airstream unhandled error. Airstream allows a maximum of one event per observable per transaction.

def tryUpdate(mods: VarTryModTuple[_]*): Unit

Modify multiple Vars in the same Transaction Example usage: Var.tryUpdate(var1 -> .map( + 1), var2 -> .map( * 2))

Modify multiple Vars in the same Transaction Example usage: Var.tryUpdate(var1 -> .map( + 1), var2 -> .map( * 2))

Note: provided mods MUST NOT THROW.

If input contains duplicate vars, reports an Airstream unhandled error. Airstream allows a maximum of one event per observable per transaction.

def update(mods: VarModTuple[_]*): Unit

Modify multiple Vars in the same Transaction Example usage: Var.update(var1 -> value1 => value1 + 1, var2 -> value2 => value2 * 2)

Modify multiple Vars in the same Transaction Example usage: Var.update(var1 -> value1 => value1 + 1, var2 -> value2 => value2 * 2)

Mod functions should be PURE.

  • If a mod throws, the var will be set to a failed state.
  • If you try to update a failed Var, Var.update will post an error to unhandled errors, and none of the Vars will update.

Reports an Airstream unhandled error:

  1. if currentValue of any of the vars is a Failure. This is atomic: an exception in any of the vars will prevent any of the batched updates in this call from going through.
  2. if input contains duplicate vars. Airstream allows a maximum of one event per observable per transaction.

Implicits

Implicits

final implicit def VarModTuple[A](tuple: (Var[A], A => A)): VarModTuple[A]
final implicit def VarTryModTuple[A](tuple: (Var[A], Try[A] => Try[A])): VarTryModTuple[A]
final implicit def VarTryTuple[A](tuple: (Var[A], Try[A])): VarTryTuple[A]
final implicit def VarTuple[A](tuple: (Var[A], A)): VarTuple[A]