tryUpdateRecord method

Future<bool>? tryUpdateRecord(
  1. KType recordId,
  2. Future update(
    1. RType? input
    )
)

Implementation

Future<bool>? tryUpdateRecord(KType recordId, Future update(RType? input)) {
  return exec(() async {
    final svc = tryGetService(recordId);
    if (svc?.currentValue == null) {
      return false;
    } else {
      var currValue = svc!.currentValue;
      final res = await update(currValue);
      if (res is RType) {
        svc.currentValue = res;

        /// Adds it to the outer stream
        addToStream(res);
      } else {
        svc.currentValue = currValue;

        /// Adds it to the outer stream
        addToStream(currValue);
      }
      return true;
    }
  });
}