Skip to content
This repository was archived by the owner on Jan 24, 2021. It is now read-only.

mkloubert/nativescript-tasks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm npm

NativeScript Tasks

A NativeScript module for simply handling background tasks via web workers.

Donate

License

MIT license

Platforms

  • Android
  • iOS

Requirements

Installation

Run

tns plugin add nativescript-tasks

inside your app project to install the module.

Example

import Tasks = require("nativescript-tasks");

Tasks.startNew((ctx) => {
                   return 23979 + ctx.state;
               },
               5979)  // 5979 will be stored in 'state'
                      // property of 'ctx' 
     .then((result) => {
               console.log('Result: ' + result.data);  // 29958
               // result.state = 5979
           })
     .catch((result) => {
               console.log('ERROR: ' + result.error);
               // result.state = 5979
            });

Limitations

  • You can only submit and return serializable objects and values!
  • All task functions are 'closures', what means that you CANNOT access variables or modules outside such functions. All functions are serialized as strings and submitted to the worker script where "external stuff" is NOT available! The only way to share data with the functions is to submit an optional and serializable "state value".

Read the official documentation to get more information.

About

NativeScript module for simply invoking and handling background tasks via web workers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors