made with esnextbin
Last active
March 2, 2017 20:54
-
-
Save Wildhoney/26cda2d5ce0e508d367744b936200a58 to your computer and use it in GitHub Desktop.
esnextbin sketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "esnextbin-sketch", | |
"version": "0.0.0", | |
"dependencies": { | |
"freelancer": "0.1.5" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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