Var is essentially a Signal that you can write to, so it's a source of state like EventBus is a source of events.
Var is essentially a Signal that you can write to, so it's a source of state like EventBus is a source of events.
There are two kinds of Vars: SourceVar and DerivedVar. The latter you can obtain by calling zoom(a => b, b => a) on a Var, however, unlike SourceVar, DerivedVar requires an Owner in order to run.
- Companion
- object
Value members
Concrete methods
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()
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 methods
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
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
Override defaultDisplayName instead of this, if you need to.
Override defaultDisplayName instead of this, if you need to.