Travis build: 980
This commit is contained in:
11
README.md
11
README.md
@ -2097,10 +2097,7 @@ Return a promise, listening for `onmessage` and `onerror` events and resolving t
|
||||
|
||||
```js
|
||||
const runAsync = fn => {
|
||||
const blob = `
|
||||
var fn = ${fn.toString()};
|
||||
this.postMessage(fn());
|
||||
`;
|
||||
const blob = `var fn = ${fn.toString()}; postMessage(fn());`;
|
||||
const worker = new Worker(
|
||||
URL.createObjectURL(new Blob([blob]), {
|
||||
type: 'application/javascript; charset=utf-8'
|
||||
@ -2123,9 +2120,9 @@ const runAsync = fn => {
|
||||
```js
|
||||
const longRunningFunction = () => {
|
||||
let result = 0;
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
for (var j = 0; j < 700; j++) {
|
||||
for (var k = 0; k < 300; k++) {
|
||||
for (let i = 0; i < 1000; i++) {
|
||||
for (let j = 0; j < 700; j++) {
|
||||
for (let k = 0; k < 300; k++) {
|
||||
result = result + i + j + k;
|
||||
}
|
||||
}
|
||||
|
||||
@ -422,10 +422,7 @@ elementIsVisibleInViewport(el, true); // true // (partially visible)
|
||||
asLink ? (window.location.href = url) : window.location.replace(url);
|
||||
</code></pre><pre><code class="language-js">redirect('https://google.com');
|
||||
</code></pre></div></div><br/><div class="card fluid"><h3 id="runasync" class="section double-padded">runAsync</h3><div class="section double-padded"><p>Runs a function in a separate thread by using a <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers">Web Worker</a>, allowing long running functions to not block the UI.</p><p>Create a new <code>Worker</code> using a <code>Blob</code> object URL, the contents of which should be the stringified version of the supplied function. Immediately post the return value of calling the function back. Return a promise, listening for <code>onmessage</code> and <code>onerror</code> events and resolving the data posted back from the worker, or throwing an error.</p><pre><code class="language-js">const runAsync = fn => {
|
||||
const blob = `
|
||||
var fn = ${fn.toString()};
|
||||
this.postMessage(fn());
|
||||
`;
|
||||
const blob = `var fn = ${fn.toString()}; postMessage(fn());`;
|
||||
const worker = new Worker(
|
||||
URL.createObjectURL(new Blob([blob]), {
|
||||
type: 'application/javascript; charset=utf-8'
|
||||
@ -442,9 +439,9 @@ elementIsVisibleInViewport(el, true); // true // (partially visible)
|
||||
};
|
||||
</code></pre><pre><code class="language-js">const longRunningFunction = () => {
|
||||
let result = 0;
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
for (var j = 0; j < 700; j++) {
|
||||
for (var k = 0; k < 300; k++) {
|
||||
for (let i = 0; i < 1000; i++) {
|
||||
for (let j = 0; j < 700; j++) {
|
||||
for (let k = 0; k < 300; k++) {
|
||||
result = result + i + j + k;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user