mutableString method

MutableCell<String> mutableString()

Return a cell which evaluates to a string representation of this cell's value.

The returned cell is a mutable computed cell. If the value of the returned cell is set explicitly, a num is parsed from the assigned string value, wrapped in a Maybe, which is assigned to this cell's value.

If an exception is thrown during parsing, a Maybe holding the exception is assigned to this cell's value.

Implementation

MutableCell<String> mutableString() =>
    MutableComputeCell(
        arguments: {this},
        compute: () => value.unwrap.toString(),
        reverseCompute: (value) {
          this.value = Maybe.wrap(() => num.parse(value));
        }
    );