Front end of the Slack clone application.

webworker-client.js 659B

1234567891011121314151617181920212223
  1. /*globals importScripts:true, self:true */
  2. importScripts("/dist/localforage.js");
  3. self.addEventListener('message', function(e) {
  4. function handleError(e) {
  5. self.postMessage({
  6. error: JSON.stringify(e),
  7. body: e,
  8. fail: true
  9. });
  10. }
  11. localforage.setDriver(e.data.driver, function() {
  12. localforage.setItem('web worker', e.data.value, function() {
  13. localforage.getItem('web worker', function(err, value) {
  14. self.postMessage({
  15. body: value
  16. });
  17. });
  18. }, handleError).catch(handleError);
  19. }, handleError);
  20. }, false);