Simple, lightweight and easy.
Multi-thread JavaScript library.
var thread = new Thread(function(){
return "hello Thread.js";
});
thread.once().done(function(d){
console.log(d); // -> hello Thread.js
});
var thread = new Thread(function(a, b){
return a + b;
});
thread.once(1, 2).done(function(d){
console.log(d); // -> 3
});
var thread = new Thread(function(){
notify("progress");
return "hello Thread.js";
});
thread.once().progress(function(d){
console.log(d); // -> progress
}).done(function(d){
console.log(d); // -> hello Thread.js
});
var thread = new Thread(function(){
example();
}, [
"http://example.com/path/to/example.js",
"http://example.com/path/to/example2.js"
]);
thread.once().progress(function(d){
// ...
});
The function passed to the constructor of Thread.js can not refer to the outer variable.
No, any object will be "deep copy". All arguments are passed by value.
<script src="https://cdn.rawgit.com/deep-rain/thread/1.0.0/dist/thread.min.js"></script>
Copyright 2017 deep-rain.com
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.