DerivedVar

class DerivedVar[A, B](parent: Var[A], zoomIn: A => B, zoomOut: B => A, owner: Owner) extends Var[B]

DerivedVar has the same Var contract as SourceVar, but instead of maintaining its own state it is essentially a lens on the underlying SourceVar.

DerivedVar has the same Var contract as SourceVar, but instead of maintaining its own state it is essentially a lens on the underlying SourceVar.

This Var is active for as long as its signal has listeners. Being a StrictSignal, it already starts out with a subscription owned by owner, but even if owner kills its subscriptions, this Var's signal might have other listeners.

trait Var[B]
trait Named
trait Sink[B]
trait SignalSource[B]
trait Source[B]
class Object
trait Matchable
class Any

Value members

Inherited methods

protected def defaultDisplayName: String

This is the method that subclasses override to preserve the user's ability to set custom display names.

This is the method that subclasses override to preserve the user's ability to set custom display names.

Inherited from
Named
final def displayName: String
Inherited from
Named
@inline
def now(): B
Throws
Exception

if currentValue is a Failure

Inherited from
Var
final def set(value: B): Unit
Inherited from
Var
def setDisplayName(name: String): DerivedVar[A, B]

Set the display name for this instance (observable or observer).

Set the display name for this instance (observable or observer).

  • This method modifies the instance and returns this. It does not create a new instance.
  • New name you set will override the previous name, if any. This might change in the future. For the sake of sanity, don't call this more than once for the same instance.
  • If display name is set, toString will output it instead of the standard type@hashcode string
Inherited from
Named
final def setError(error: Throwable): Unit
Inherited from
Var
def setTry(tryValue: Try[B]): Unit
Inherited from
Var
def someWriter[V](evidence: Option[V] <:< B): Observer[V]

Write values into a Var of Option[V] without manually wrapping in Some()

Write values into a Var of Option[V] without manually wrapping in Some()

Inherited from
Var
override def toObservable: Signal[B]
Definition Classes
Inherited from
Var
override def toObserver: Observer[B]
Definition Classes
Inherited from
Var
final override def toString: String

Override defaultDisplayName instead of this, if you need to.

Override defaultDisplayName instead of this, if you need to.

Definition Classes
Named -> Any
Inherited from
Named
@inline
def tryNow(): Try[B]
Inherited from
Var
def tryUpdate(mod: Try[B] => Try[B]): Unit
Value Params
mod

Note: must not throw

Throws
Exception

if mod throws

Inherited from
Var
def tryUpdater[B](mod: (Try[B], B) => Try[B]): Observer[B]
Value Params
mod

(currValue, nextInput) => nextValue Note: Must not throw!

Inherited from
Var
def update(mod: B => B): Unit

Do not use on failed Vars. Use tryUpdate on those.

Do not use on failed Vars. Use tryUpdate on those.

Value Params
mod

Note: guarded against exceptions

Inherited from
Var
def updater[B](mod: (B, B) => B): Observer[B]

An observer much like writer, but can compose input events with the current value of the var, for example:

An observer much like writer, but can compose input events with the current value of the var, for example:

val v = Var(List(1, 2, 3)) val appender = v.updater((acc, nextItem) => acc :+ nextItem) appender.onNext(4) // v now contains List(1, 2, 3, 4)

Do not use on failed Vars. Use tryUpdater on those.

Value Params
mod

(currValue, nextInput) => nextValue

Inherited from
Var
def zoom[B](in: B => B)(out: B => B)(owner: Owner): Var[B]
Inherited from
Var

Concrete fields

override val signal: StrictSignal[B]

Inherited fields

val writer: Observer[B]
Inherited from
Var