single<T> static method
Implementation
static Future<T> single<T>(
Object? intialValue,
Future<T> Function(Object? data) test,
) async {
final BuildIsolate isolate = BuildIsolate();
final Completer<T> completer = Completer<T>();
await isolate.init(
onIsolateDataRecived: (data, sendPort) async {
printAmber("$data", prefix: "isolate");
// sendPort.send(await test(data));
},
onDataRecived: (data, sendPort) {
printAmber("$data", prefix: "main");
// if (data is T) completer.complete(data);
},
);
completer.future.then((value) => isolate.dispose());
return completer.future;
}