updateOwnData method

MessageActionDescriptor<M, D, C> updateOwnData(
  1. D update(
    1. MessageHandlerContext<M, D, C> ctx
    ), {
  2. String? label,
})

Implementation

MessageActionDescriptor<M, D, C> updateOwnData(
  D Function(MessageHandlerContext<M, D, C> ctx) update, {
  String? label,
}) {
  var info = MessageActionInfo(ActionType.updateData, null, D, label);
  return MessageActionDescriptor(info, (ctx) {
    _log.fine(() => "State '$_forState' is updating data of type $D");
    var data = _forState is DataStateKey<D>
        ? ctx.messageContext.data(_forState)
        : throw StateError(
            'Unable to find data value of type $D in active data states');
    data.update((current) => update(ctx));
  });
}