polling_request 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,6 +42,9 @@ class PollingRequest
42
42
  _run: ->
43
43
  $.ajax
44
44
  url: @options.url
45
+ cached: false # what does 304 not modified mean in this context?
46
+ accepts:
47
+ json: 'application/json'
45
48
  beforeSend: (jqXHR, settings) =>
46
49
  @status = 'running'
47
50
  statusCode:
@@ -4,7 +4,7 @@
4
4
 
5
5
  PollingRequest = (function() {
6
6
  function PollingRequest(options) {
7
- var _base, _base1, _base2, _base3;
7
+ var _base, _base1, _base2, _base3, _base4;
8
8
  this.options = options;
9
9
  this.progress = 0;
10
10
  this.status = 'pending';
@@ -12,6 +12,7 @@
12
12
  (_base1 = this.options).success || (_base1.success = function() {});
13
13
  (_base2 = this.options).progress || (_base2.progress = function() {});
14
14
  (_base3 = this.options).error || (_base3.error = function() {});
15
+ (_base4 = this.options).stopped || (_base4.stopped = function() {});
15
16
  }
16
17
 
17
18
  PollingRequest.prototype.start = function() {
@@ -27,7 +28,8 @@
27
28
  PollingRequest.prototype.stop = function() {
28
29
  this.status = 'stopped';
29
30
  clearInterval(this.timer);
30
- return this.timer = null;
31
+ this.timer = null;
32
+ return this.options.stopped();
31
33
  };
32
34
 
33
35
  PollingRequest.prototype.status = function() {
@@ -42,6 +44,10 @@
42
44
  var _this = this;
43
45
  return $.ajax({
44
46
  url: this.options.url,
47
+ cached: false,
48
+ accepts: {
49
+ json: 'application/json'
50
+ },
45
51
  beforeSend: function(jqXHR, settings) {
46
52
  return _this.status = 'running';
47
53
  },
@@ -53,7 +59,7 @@
53
59
  },
54
60
  202: function(data, textStatus, jqXHR) {
55
61
  _this.progress = data.progress || 0;
56
- return _this.options.progress(data.progress);
62
+ return _this.options.progress(_this.progress);
57
63
  }
58
64
  },
59
65
  error: function(jqXHR, textStatus, errorThrown) {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polling_request
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: