amatriain/feedbunch

View on GitHub
FeedBunch-app/app/assets/javascripts/workers/refresh_feed_worker.js.erb

Summary

Maintainability
Test Coverage
/**
 * Web Worker to request a feed refresh in a separate thread.
 */

importScripts('<%= asset_path 'workers/common/do_put' %>');

// Callback for messages from the main thread
onmessage = function(e){
  // CSRF token
  var token = e.data.token;

  // ID of the feed to refresh
  var feed_id = e.data.feed_id;

  var url = "/api/feeds/" + feed_id + ".json";

  do_put("refresh_feed", url, token, {}, 0);
}