Skip to content

Instantly share code, notes, and snippets.

@Wildhoney
Last active March 2, 2017 20:54
Show Gist options
  • Save Wildhoney/26cda2d5ce0e508d367744b936200a58 to your computer and use it in GitHub Desktop.
Save Wildhoney/26cda2d5ce0e508d367744b936200a58 to your computer and use it in GitHub Desktop.
esnextbin sketch
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ESNextbin Sketch</title>
<style type="text/css">
main {
font-family: Arial, Tahoma, Helvetica, sans-serif;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
img {
width: 100%;
}
p {
font-style: italic;
}
</style>
</head>
<body>
<main>
<img src="https://github.com/Wildhoney/Freelancer/blob/master/media/logo.png?raw=true" alt="Freelancer" />
<p>Open console and press <strong>execute</strong> to see result of ping, pong exchange.</p>
</main>
</body>
</html>
import { Freelancer } from 'freelancer';
const options = { send: 'Ping?', respond: 'Pong!' };
const worker = new Freelancer(options => {
self.addEventListener('message', event => {
console.log(event.data);
self.postMessage(options.respond);
});
}, options);
worker.addEventListener('message', event => console.log(event.data));
worker.postMessage(options.send);
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"freelancer": "0.1.5"
}
}
'use strict';
var _freelancer = require('freelancer');
var options = { send: 'Ping?', respond: 'Pong!' };
var worker = new _freelancer.Freelancer(function (options) {
self.addEventListener('message', function (event) {
console.log(event.data);
self.postMessage(options.respond);
});
}, options);
worker.addEventListener('message', function (event) {
return console.log(event.data);
});
worker.postMessage(options.send);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment