##ng-vkThread Angular version of the vkThread plugin, which allows you to execute a function in a separate thread.
Function can be defined directly in the main thread or called from an external javascript file.
Function can be:
- Regular functions
- Object's methods
- Functions with dependencies
- Functions with context
- Anonymous functions
Plugin is built on HTML5 "Web Worker" technology.
- file size: 3.3k minified / 5.3k development
- Doesn't have any dependencies.
Basic usage:
- install with bower
bower install ng-vkthread
- integrate plugun in your project:
<script src="../vkthread/vkthread.min.js" type="text/javascript"></script>
var app = angular.module('myApp',['ng-vkThread']);
app.controller('ExampleController', ['$scope', 'vkThread',
function($scope, vkThread){
var vkThread = vkThread();
. . .
}
- create function
/* function to execute in a thread */
function foo(n, m){
return n + m;
}
- execute this function in a thread
/* create an object, which you pass to vkThread as an argument*/
var param = {
fn: foo // <-- function to execute
args: [1, 2] // <-- arguments for this function
};
/* run thread */
vkThread.exec(param).then(
function (data) {
console.log(data); // <-- thread returns 3
},
function(err) {
alert(err); // <-- thread returns error message
}
);
######Documentation & Examples: ( http://www.eslinstructor.net/ng-vkthread/demo/ )