Skip to content

Commit

Permalink
Fixed issue: Cannot add new events after calling close
Browse files Browse the repository at this point in the history
  • Loading branch information
lamnhan066 committed Dec 18, 2024
1 parent 037c60f commit 847a37e
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class IsolateContactorControllerImplFuture<R, P>
_onDispose?.call();
unawaited(close());
} else {
if (_isolateStreamController.isClosed) break;

_isolateStreamController.add(value as P);
}
}
Expand Down Expand Up @@ -74,27 +76,39 @@ class IsolateContactorControllerImplFuture<R, P>
Stream<P> get onIsolateMessage => _isolateStreamController.stream;

@override
void initialized() => _delegate.sink.add(
<IsolatePort, IsolateState>{IsolatePort.main: IsolateState.initialized},
);
void initialized() {
if (_delegate.isClosed) return;

_delegate.sink.add(
<IsolatePort, IsolateState>{IsolatePort.main: IsolateState.initialized},
);
}

@override
void sendIsolate(P message) {
if (_delegate.isClosed) return;

_delegate.sink.add(<IsolatePort, P>{IsolatePort.isolate: message});
}

@override
void sendIsolateState(IsolateState state) {
if (_delegate.isClosed) return;

_delegate.sink.add(<IsolatePort, IsolateState>{IsolatePort.isolate: state});
}

@override
void sendResult(R message) {
if (_delegate.isClosed) return;

_delegate.sink.add(<IsolatePort, R>{IsolatePort.main: message});
}

@override
void sendResultError(IsolateException exception) {
if (_delegate.isClosed) return;

_delegate.sink
.add(<IsolatePort, IsolateException>{IsolatePort.main: exception});
}
Expand Down

1 comment on commit 847a37e

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage for this commit

93.72%

Coverage Report for Changed Files
FileStmtsBranchesFuncsLinesUncovered Lines
lib/src/base/contactor/isolate_contactor_controller/web_platform
   isolate_contactor_controller_web.dart100%100%100%100%

Please sign in to comment.