isolate_contactor
An easy way to create a new Isolate, keep it active and communicate with it (supports `Worker` and `WASM` on the Web platform).
4.2.0
27K downloads/mo
#1917 most downloaded on pub.dev
lamnhan066/isolate_contactor
What this package is like to depend on
Last release 2 years ago
no release in 18 months
Release timing varies
gaps range from 8 days to 9 months
Nearly every release is documented
notes for 27 of 30 stable releases
Nothing withdrawn
no release was ever pulled
5 years old
37 releases · first in 2021
0 releases in the last 12 months
see the full history below
Release timeline
37 releases · Nov 2021 to May 2024Releases
latest 37-
4.2.002 May 2024Release notes
Open source →- Migrate to
package:webfromdart:htmlto supportwasm. - Experiment: Able to send an
initializedsignal from the Isolate to the main app. The migration steps:-
Step 1:
-
Advanced method:
- Before:
final channel = IsolateContactorController<double, List<double>>(params); channel.onIsolateMessage.listen((message) { channel.sendResult(add(message)); });- After:
final channel = IsolateContactorController<double, List<double>>(params); channel.onIsolateMessage.listen((message) { channel.sendResult(add(message)); }); channel.initialized(); // <-- -
Worker on the Web:
- Before:
main() { callbackToStream('onmessage', (html.MessageEvent e) { return js_util.getProperty(e, 'data'); }).listen((message) async { jsSendMessage(add(message)); }); }- After:
main() async { // Do something sync or async here callbackToStream('onmessage', (html.MessageEvent e) { return js_util.getProperty(e, 'data'); }).listen((message) async { jsSendMessage(add(message)); }); jsSendMessage(IsolateState.initialized.toJson()); // <-- }
-
-
Step 2: Update the
createandcreateOwnIsolatemethod:- Before:
final isolate = await IsolateContactor.create( function, workerName: 'function', );- After:
final isolate = await IsolateContactor.create( function, workerName: 'function', autoMarkAsInitialized: false, // <-- );
-
- Migrate to
-
4.2.0-rc.401 May 2024 pre-releaseNothing published for this version
-
4.2.0-rc.330 Apr 2024 pre-releaseNothing published for this version
-
4.2.0-rc.229 Apr 2024 pre-releaseNothing published for this version
-
4.2.0-rc.129 Apr 2024 pre-releaseNothing published for this version
-
4.1.025 Apr 2024Release notes
Open source →- Use
if (dart.library.io)instead ofif (dart.library.html)for more compatible. - Deprecate the
createOwnIsolatein favor of thecreateCustom. - Add typedefs:
IsolateFunction,CustomIsolateFunction,IsolateConverter. - Remove
workerfolder. - The
READMEis cleared and isn't maintained anymore. Read in the isolate_manager instead.
- Use
-
4.0.104 Apr 2024 -
4.0.010 Jul 2023Release notes
Open source →- Add
sendResultErrortoIsolateContactorControllerto make it easier to send the Exception from the Isolate to main app. IsolateExceptionparameters are nowObjectandStackTrace.- Add parameter type as
Pand change return type toR. - Add return type as
voidtoonDisposemethod. - Change
isolateParamsfrom dynamic toObject?.
- Add
-
4.0.0-rc.205 Jul 2023 pre-releaseNothing published for this version
-
4.0.0-rc.105 Jul 2023 pre-releaseNothing published for this version
-
3.0.014 May 2023Release notes
Open source →- Bumped Dart sdk to
>=2.18.0 <4.0.0. - Update
error_function.jsname in test.
- Bumped Dart sdk to
-
2.1.030 Jan 2023Release notes
Open source →- Support
try-catchblock for all platforms including Worker on Web. - Update
worker.dartto supporttry-catchblock. - Increase min SDK to 2.15.0.
- Support
-
2.1.0-PRE.126 Jan 2023 pre-releaseNothing published for this version
-
2.0.214 Jan 2023Release notes
Open source →- On Flutter >3.3.0 -
@pragma('vm:entry-point')anotation must be added to all methods that you want to use for isolation. Read README for more information. - Add
@pragma('vm:entry-point')to internal method. - Use
stream_channel: ^2.1.0to avoid conflicts withflutter_test.
- On Flutter >3.3.0 -
-
2.0.2+125 Jan 2023 -
2.0.115 Dec 2022 -
2.0.024 Jun 2022Release notes
Open source →- NO BREAKING CHANGE
- Add
Workerfor Web platform (real Isolate on Web). Read README for more details.
-
2.0.0+113 Oct 2022 -
1.7.023 Jun 2022Release notes
Open source →- BREAKING CHANGE: Change parameter name from
isolateParamstoinitialParamsforcreateOwnIsolate. - Now you can get the
initialParamswhen creating an own isolate:
void isolateFunction(dynamic params) { var controller = IsolateContactorController(params, onDispose: () {}); var initialParams = controller.initialParams; controller.onIsolateMessage.listen((message) { // Do your stuff here }); } - BREAKING CHANGE: Change parameter name from
-
1.6.122 Jun 2022Release notes
Open source →- Added
IsolateContactorException, throw it when error occurs onsendMessagemethod. - Return
Futurefordisposemethod.
- Added
-
1.6.021 Jun 2022Release notes
Open source →- Now you can
awaitfor the result when usingisolateContactor.sendMessage. - Improved README and Test.
- Now you can
-
1.5.112 Jun 2022Nothing published for this version
-
1.5.1+112 Jun 2022Release notes
Open source →- Improved result parser.
- Improved README for allowed return type version, Improved Test and Example.
-
1.5.011 Jun 2022Nothing published for this version
-
1.5.0+111 Jun 2022Release notes
Open source →- Now you can add return type for the stream listener. Example:
// `fibonacci` have `int` return type IsolateContactor<int> isolateContactor = await IsolateContactor.create(fibonacci); // `intEvent` will be `int` type isolateContactorFuture.onMessage.listen((intEvent) { // intEvent }); // `fibonacci` have `int` return type int fibonacci(dynamic n) { if (n <= 2) return 1; int n1 = 0, n2 = 1, n3 = 1; for (int i = 2; i <= n; i++) { n3 = n1 + n2; n1 = n2; n2 = n3; } return n3.round(); }- Add
onDisposeparameter toIsolateContactorController, this parameter allows you to add your own dispose method insideisolateFunctionfor.createOwnIsolate.
-
1.4.003 Jun 2022 -
1.3.018 May 2022 -
1.2.103 May 2022 -
1.2.026 Nov 2021Release notes
Open source →- Fixed issue with the
restartmethod. - Cleanup and reformat internal code.
- BREAKING CHANGE:
- Temporarily removed the
pauseandresumemethods. - The
debugModein thecreate()andcreateOwnIsolate()methods was refactored to named optional parameters.
- Temporarily removed the
- Fixed issue with the
-
1.2.0+129 Jan 2022 -
1.2.0+228 Feb 2022 -
1.1.020 Nov 2021Nothing published for this version
-
1.1.0+120 Nov 2021Release notes
Open source →- Remove flutter dependencies to support dart native
- Add a better description
-
1.0.018 Nov 2021Release notes
Open source →- Support web platform with limited features. The package use
Futureto provide the same features toIsolatebut it doesn't havepause,resume,restartmethods. I'll try to bring the same action withIsolateas much as possible. - Support
Futurewhen creating build-in method. More information please read Readme. - BREAKING CHANGE:
-
Create your own isolate:
Before:
void isolateFunction(List<dynamic> params) { final channel = IsolateChannel.connectSend(params.last); channel.stream.listen((rawMessage) { final message = IsolateContactor.getMessage(rawMessage); if (message != null) { // Do more stuff here // Send the result to your [onMessage] stream channel.sendResult(add(message[0], message[1])); } }Now:
void isolateFunction(dynamic params) { final channel = IsolateContactorController(params); channel.onIsolateMessage.listen((message) { // Do more stuff here // Send the result to your [onMessage] stream channel.sendResult(add(message[0], message[1])); }); }
-
- Support web platform with limited features. The package use
-
0.0.117 Nov 2021 -
0.0.1+117 Nov 2021 -
0.0.1+217 Nov 2021