LCOV - code coverage report
Current view: top level - src/isolate_factory - web_isolate_factory.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 20 20 100.0 %
Date: 2022-12-12 00:09:36 Functions: 0 0 -

          Line data    Source code
       1             : import 'dart:async';
       2             : 
       3             : import 'package:combine/src/combine_info.dart';
       4             : import 'package:combine/src/combine_isolate/web_combine_isolate.dart';
       5             : import 'package:combine/src/isolate_context.dart';
       6             : import 'package:combine/src/isolate_factory/isolate_factory.dart';
       7             : import 'package:combine/src/isolate_messenger/internal_isolate_messenger/web_internal_isolate_messenger.dart';
       8             : 
       9             : class WebIsolateFactory extends IsolateFactory {
      10           1 :   @override
      11             :   Future<CombineInfo> create<T>(
      12             :     IsolateEntryPoint<T> entryPoint, {
      13             :     Map<String, Object?>? argumentsMap,
      14             :     T? argument,
      15             :     String? debugName,
      16             :     bool errorsAreFatal = true,
      17             :   }) async {
      18             :     // Will be closed by [WebCombineIsolate.kill].
      19             :     // ignore: close_sinks
      20           1 :     final fromIsolate = StreamController<Object?>();
      21             :     // ignore: close_sinks
      22           1 :     final toIsolate = StreamController<Object?>();
      23           2 :     final toIsolateStream = toIsolate.stream.asBroadcastStream();
      24           2 :     final fromIsolateStream = fromIsolate.stream.asBroadcastStream();
      25             : 
      26           1 :     final isolateMessenger = WebInternalIsolateMessenger(
      27             :       fromIsolateStream,
      28           1 :       toIsolate.sink,
      29             :     );
      30             : 
      31           1 :     final context = IsolateContext(
      32           1 :       messenger: WebInternalIsolateMessenger(
      33             :         toIsolateStream,
      34           1 :         fromIsolate.sink,
      35           1 :       ).toIsolateMessenger(),
      36             :       argument: argument,
      37           1 :       isolate: WebCombineIsolate(() {}),
      38             :     );
      39             : 
      40           2 :     runZoned(() {
      41           1 :       entryPoint(context);
      42             :     });
      43             : 
      44           1 :     return CombineInfo(
      45           2 :       isolate: WebCombineIsolate(() {
      46           1 :         fromIsolate.close();
      47           1 :         toIsolate.close();
      48           1 :         isolateMessenger.markAsClosed();
      49             :       }),
      50           1 :       messenger: isolateMessenger.toIsolateMessenger(),
      51             :     );
      52             :   }
      53             : }
      54             : 
      55             : /// This typedef is used for conditional import.
      56             : typedef IsolateFactoryImpl = WebIsolateFactory;

Generated by: LCOV version 1.16