Sha256: 75db28dfd2d607068740f3266894b35ede611fabca7d553e3d73559bca5d817d

Contents?: true

Size: 1006 Bytes

Versions: 1

Compression:

Stored size: 1006 Bytes

Contents

//= require action_cable

(function() {
  // Setup ActionCable connection
  this.App || (this.App = {});
  App.active_job_channel_cable = ActionCable.createConsumer('/cable/active_job_channel');

  // Setup up ActiveJobChannel received method
  this.ActiveJobChannel || (this.ActiveJobChannel = {});
  ActiveJobChannel.received = ActiveJobChannel.received || function(data) {
    var status = data.status;
    var job_name = data.job_name;
    if (status === 'success') { console.log(job_name + ' succeeded!'); }
    else if (status === 'failure') { console.log(job_name + ' failed!'); }
    else { console.error('Job status could not be determined'); }
  }

}).call(this);

// Setup ActionCable subscriber
document.addEventListener("DOMContentLoaded", function (_event) {
  const CHANNEL = "::ActiveJobChannel::Channel";
  App.active_job_channel = App.active_job_channel_cable.subscriptions.create(
    { channel: CHANNEL },
    { received: function (data) { ActiveJobChannel.received(data); } }
  );
});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_job_channel-0.0.1 app/assets/javascripts/active_job_channel.js