Coder Social home page Coder Social logo

isolate_classy's Introduction

It makes very easy and elegant for your asynchronous functions to run on isolate, just add ".isolate" or ".isolateX" (x is the number [1-6])

Features

Just call ".isolate" or ".isolateX" to make your asynchronous function to run on isolate

Getting started

import 'package:isolate_classy/isolate_classy.dart';

Usage

  • 1.Asynchronous functions without named parameters run on isolate

Just add ".isolate" to the name of a function to make it run on a isolate。

Future<int> func(int a1,int a2,int a3) async{
}

await func(1,2,3);//runs on the main isolate
await func.isolate(1,2,3);//runs on the new isolate
  • 2.Asynchronous functions with named parameters run on isolate
Future<int> func({double width,double height,Color? color})async{
}
Future<int> func6(int a1,int a2,int a3,int a4,int a5,int a6,{double width,double height,Color? color})async{
}

await func.isolate({#width:100,#height:200,#color: Colors.blue});//There are no positional parameters
await func1.isolate1(1,{#width:100,#height:200,#color: Colors.blue});//1 positional parameters
//...
await func1.isolate6(1,2,3,4,5,6,{#width:100,#height:200,#color: Colors.blue});//6 positional parameters

Additional information

This article explains the principle.

If an asynchronous function with named parameters uses the return value, you need to specify the return value type.

int ret=await func.isolate({#width:100,#height:200,#color: Colors.blue});
//or
ret=await func.isolate<int>({#width:100,#height:200,#color: Colors.blue});

isolate_classy's People

Contributors

gold-duo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.