maybe method

MaybeCell<T> maybe()

Creates a MaybeCell which wraps this cell's value.

The returned cell is a mutable computed cell that wraps this cell's value in a Maybe.

When the MaybeCell's value is assigned, the value of this cell is set to the value wrapped by the Maybe if the Maybe is holding a value. If the Maybe holds an exception, the value of this cell is unchanged.

Implementation

MaybeCell<T> maybe() {
  return MutableComputeCell(arguments: {this}, compute: () => Maybe(value), reverseCompute: (maybe) {
    try {
      value = maybe.unwrap;
    }
    catch (e) {
      // Do Nothing
    }
  });
}