vm property

Model vm

Once the view-model is created, and as long as it's not null, you can reference it by using the vm getter. This is meant to be used inside of Factory methods.

Example:

ViewModel fromStore() =>
  ViewModel(
    value: _calculateValue(),
    onTap: _onTap);
  }

// Here we use the value, without having to recalculate it.
void _onTap() => dispatch(SaveValueAction(vm.value));

Implementation

Model get vm {
  if (!_vmCreated)
    throw StoreException("You can't reference the view-model "
        "before it's created and returned by the fromStore method.");

  if (_vm == null)
    throw StoreException("You can't reference the view-model, "
        "because it's null.");

  return _vm!;
}