Skip to content

Instantly share code, notes, and snippets.

@mikehibm
Last active November 14, 2018 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikehibm/a83d2b343f994f10b688aea5d38d1ccf to your computer and use it in GitHub Desktop.
Save mikehibm/a83d2b343f994f10b688aea5d38d1ccf to your computer and use it in GitHub Desktop.
/* eslint no-restricted-globals: ["error"] */
export default () => {
let count = 0;
self.addEventListener(
'message',
function(e) {
if (e.data.action === 'count') {
count++;
}
if (e.data.action === 'clear') {
count = 0;
}
postMessage({ msg: 'count' + count, count: count });
},
false
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment