select<T> method

ValueCell<T> select<T>(
  1. ValueCell<T> ifTrue, [
  2. ValueCell<T>? ifFalse
])

Create a new cell which selects between the values of two cells based on this.

If this is true, the cell evaluates to the value of ifTrue.

If this is false, the cell evaluates to the value of ifFalse if it is a cell. Otherwise if ifFalse is null, the cell's value is not updated.

Implementation

ValueCell<T> select<T>(ValueCell<T> ifTrue, [ValueCell<T>? ifFalse]) => ifFalse != null
    ? ValueCell.computed(() => this() ? ifTrue() : ifFalse())
    : ValueCell.computed(() => this() ? ifTrue() : ValueCell.none());