functions property

Map<String, Future Function(dynamic value)> functions
final

The functions related to working with a Future

Implementation

static final functions = {
  'await': (value) => value is Future
      ? value
      : throw Exception(
          '[await]: expected [value] to be a Future but encountered: ${value?.runtimeType}',
        ),
  'delay': (value) => value is Duration
      ? Future.delayed(value)
      : value is String || value is num
          ? Future.delayed(JsonClass.parseDurationFromMillis(value))
          : throw Exception(
              '[delay]: expected [value] to be a Duration, a String, or a num but encountered: ${value?.runtimeType}',
            ),
  'delayed': (value) => value is Duration
      ? Future.delayed(value)
      : value is String || value is num
          ? Future.delayed(JsonClass.parseDurationFromMillis(value))
          : throw Exception(
              '[delayed]: expected [value] to be a Duration, a String, or a num but encountered: ${value?.runtimeType}',
            ),
};