lexmihaylov/AsyncUtils

View on GitHub
examples/threaded-function.html

Summary

Maintainability
Test Coverage
<!DOCTYPE html>
<html>
    <body>
        <script type="text/javascript" src="../AsyncUtils.js"></script>
        
        <script>
            var printSomething = AsyncUtils.threaded(function(something) {
                var i = 0;
                while(i <= 10000000000) {i++;} // this will not block the ui because it run inside a worker
                console.log(something);
                
                return 'executed in a thread';
            });
            
            printSomething('Hello, World').then(function(val) {
                console.log(val);
            });
            
            console.log('this will be executed before `printSomething`');
        </script>
    </body>
</html>