onSpawned method

  1. @override
FutureOr<bool> onSpawned()
override

Called when an Isolate is spawned and receives a Spawnable instance.

Implementation

@override
FutureOr<bool> onSpawned() {
  var returns = <FutureOr<bool>>[];

  try {
    var ret = storage.onSpawned();
    returns.add(ret);
  } catch (e, s) {
    print(e);
    print(s);
  }

  try {
    var ret = releaseProvider.onSpawned();
    returns.add(ret);
  } catch (e, s) {
    print(e);
    print(s);
  }

  if (returns.isEmpty) return false;

  if (returns.whereType<Future>().isEmpty) {
    return returns.map((e) => e as bool).where((r) => r == false).isEmpty;
  } else {
    return Future.wait(returns.map((e) => Future.sync(() => e))).then((oks) {
      return returns.where((r) => r == false).isEmpty;
    });
  }
}