Target
To execute intensive computations and avoid blocking the responsiveness of your web app, use dart:isolate to achieve it.Dynamics
Filling Station:Procedures of creation of Isolate
- Check the live demo and get code at Github
- Official API – dart:isolate
Step 1. create a “RecievePort” for main thread
Step 2. spwan a new isolate and handover your “SendPort” to spawned isolate. So far the road to right side is carfed
Step 3. isolate thread spwaned and “SendPort” passed-in
Step 4. create a “RecievePort” for isolate thread itself
Step 5. send back “SendPort” of isolate thread to main thread via passed-in “SendPort”. Now 2-way communication is built
Landing
In lib/main_app.dart, spawn Isolate and send messages like this:
In web/remote_isolate.dart, initialize spawned Isolate and send back messages like this:
Tips: All Isolate programs must be put under the web folder