Skip to content

Angular plugin, which makes possible to execute function in a thread.

License

Notifications You must be signed in to change notification settings

parmantolab/ng-vkthread

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

##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/ )

About

Angular plugin, which makes possible to execute function in a thread.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%