Last active
November 14, 2018 22:24
-
-
Save mikehibm/a83d2b343f994f10b688aea5d38d1ccf to your computer and use it in GitHub Desktop.
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
/* 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