render_async 2.1.10 β†’ 2.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c2458365f2d0d1c95a9356e4076e483b41e58518a6c0496d0b2d20c8a0c1e44
4
- data.tar.gz: 9fce775541e8e12fe742a0ec03dfb52a92f47ac70c953442d74e612f721d0480
3
+ metadata.gz: 5eb3554f389bd0bcab8944c56c59238359d1c181c7dbc212d12e0335a9960fa6
4
+ data.tar.gz: a00cfb7925232e67825579356c33707d97258d369d41d92f676077c6e0b1d17e
5
5
  SHA512:
6
- metadata.gz: c1a00f85f23df409ba9a505c963359979512c32110096a3b7bf5431942a0a8274711fc2000a909f379d76a921548854bb3bc005e0cc6f6a31b8f46d94692c6f2
7
- data.tar.gz: 8aab5df90bf0db84a3c4c82adf6eec772de19b553b9bdcd0d08646fdd20f522eb4cc4d41e7ef335aa856557e8f892cd8f3d7f2507938f042d8f0eaf3988bff75
6
+ metadata.gz: acd95e67267622528c723d41ba5dfe1114319173f3455004523fd0dab784d8626a21314a389373f473d5147465e29773defb75c40d7ff6cb15053b7eba44e1a2
7
+ data.tar.gz: ccb2a071554bdca88a02b8b3b178711b01d116067eda7d48f01385056459cd3f59e8561d489ce76380be26ad8979398f40300759915c07962899aef608751e24
data/.all-contributorsrc CHANGED
@@ -138,7 +138,8 @@
138
138
  "avatar_url": "https://avatars3.githubusercontent.com/u/1935686?v=4",
139
139
  "profile": "https://github.com/reneklacan",
140
140
  "contributions": [
141
- "code"
141
+ "code",
142
+ "doc"
142
143
  ]
143
144
  },
144
145
  {
data/README.md CHANGED
@@ -402,6 +402,20 @@ Here is an example on how to get `retryCount`:
402
402
  </script>
403
403
  ```
404
404
 
405
+ If you need to pass retry count to the backend, you can pass `retry_count_header` in `render_async`'s options:
406
+
407
+ ```erb
408
+ <%= render_async users_path,
409
+ retry_count: 5,
410
+ retry_count_header: 'Retry-Count-Current' %>
411
+ ```
412
+
413
+ And then in controller you can read the value from request headers.
414
+
415
+ ```
416
+ request.headers['Retry-Count-Current']&.to_i
417
+ ```
418
+
405
419
  ### Toggle event
406
420
 
407
421
  You can trigger `render_async` loading by clicking or doing another event to a
@@ -794,7 +808,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
794
808
  <!-- prettier-ignore -->
795
809
  | [<img src="https://avatars2.githubusercontent.com/u/3028124?v=4" width="100px;"/><br /><sub><b>Nikola Đuza</b></sub>](https://nikolalsvk.github.io)<br />[πŸ’¬](#question-nikolalsvk "Answering Questions") [πŸ’»](https://github.com/renderedtext/render_async/commits?author=nikolalsvk "Code") [πŸ“–](https://github.com/renderedtext/render_async/commits?author=nikolalsvk "Documentation") [πŸ‘€](#review-nikolalsvk "Reviewed Pull Requests") | [<img src="https://avatars0.githubusercontent.com/u/3866868?v=4" width="100px;"/><br /><sub><b>Colin</b></sub>](http://www.colinxfleming.com)<br />[πŸ’»](https://github.com/renderedtext/render_async/commits?author=colinxfleming "Code") [πŸ“–](https://github.com/renderedtext/render_async/commits?author=colinxfleming "Documentation") [πŸ’‘](#example-colinxfleming "Examples") | [<img src="https://avatars2.githubusercontent.com/u/334273?v=4" width="100px;"/><br /><sub><b>Kasper Grubbe</b></sub>](http://kaspergrubbe.com)<br />[πŸ’»](https://github.com/renderedtext/render_async/commits?author=kaspergrubbe "Code") | [<img src="https://avatars2.githubusercontent.com/u/163584?v=4" width="100px;"/><br /><sub><b>Sai Ram Kunala</b></sub>](https://sairam.xyz/)<br />[πŸ“–](https://github.com/renderedtext/render_async/commits?author=sairam "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/3065882?v=4" width="100px;"/><br /><sub><b>Josh Arnold</b></sub>](https://github.com/nightsurge)<br />[πŸ’»](https://github.com/renderedtext/render_async/commits?author=nightsurge "Code") [πŸ“–](https://github.com/renderedtext/render_async/commits?author=nightsurge "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/107798?v=4" width="100px;"/><br /><sub><b>Elad Shahar</b></sub>](https://eladshahar.com)<br />[πŸ’»](https://github.com/renderedtext/render_async/commits?author=SaladFork "Code") [πŸ’‘](#example-SaladFork "Examples") | [<img src="https://avatars3.githubusercontent.com/u/232392?v=4" width="100px;"/><br /><sub><b>Sasha</b></sub>](http://www.revzin.co.il)<br />[πŸ’»](https://github.com/renderedtext/render_async/commits?author=sasharevzin "Code") [πŸ“–](https://github.com/renderedtext/render_async/commits?author=sasharevzin "Documentation") |
796
810
  | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
797
- | [<img src="https://avatars3.githubusercontent.com/u/50223?v=4" width="100px;"/><br /><sub><b>Ernest Surudo</b></sub>](http://elsurudo.com)<br />[πŸ’»](https://github.com/renderedtext/render_async/commits?author=elsurudo "Code") | [<img src="https://avatars1.githubusercontent.com/u/334809?v=4" width="100px;"/><br /><sub><b>Kurtis Rainbolt-Greene</b></sub>](https://kurtis.rainbolt-greene.online)<br />[πŸ’»](https://github.com/renderedtext/render_async/commits?author=krainboltgreene "Code") | [<img src="https://avatars2.githubusercontent.com/u/59744?v=4" width="100px;"/><br /><sub><b>Richard Schneeman</b></sub>](https://www.schneems.com)<br />[πŸ“–](https://github.com/renderedtext/render_async/commits?author=schneems "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/75705?v=4" width="100px;"/><br /><sub><b>Richard Venneman</b></sub>](https://www.cityspotters.com)<br />[πŸ“–](https://github.com/renderedtext/render_async/commits?author=richardvenneman "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/381395?v=4" width="100px;"/><br /><sub><b>Filipe W. Lima</b></sub>](https://github.com/filipewl)<br />[πŸ“–](https://github.com/renderedtext/render_async/commits?author=filipewl "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/3135638?v=4" width="100px;"/><br /><sub><b>JesΓΊs Eduardo Clemens Chong</b></sub>](https://github.com/eclemens)<br />[πŸ’»](https://github.com/renderedtext/render_async/commits?author=eclemens "Code") | [<img src="https://avatars3.githubusercontent.com/u/1935686?v=4" width="100px;"/><br /><sub><b>RenΓ© Klačan</b></sub>](https://github.com/reneklacan)<br />[πŸ’»](https://github.com/renderedtext/render_async/commits?author=reneklacan "Code") |
811
+ | [<img src="https://avatars3.githubusercontent.com/u/50223?v=4" width="100px;"/><br /><sub><b>Ernest Surudo</b></sub>](http://elsurudo.com)<br />[πŸ’»](https://github.com/renderedtext/render_async/commits?author=elsurudo "Code") | [<img src="https://avatars1.githubusercontent.com/u/334809?v=4" width="100px;"/><br /><sub><b>Kurtis Rainbolt-Greene</b></sub>](https://kurtis.rainbolt-greene.online)<br />[πŸ’»](https://github.com/renderedtext/render_async/commits?author=krainboltgreene "Code") | [<img src="https://avatars2.githubusercontent.com/u/59744?v=4" width="100px;"/><br /><sub><b>Richard Schneeman</b></sub>](https://www.schneems.com)<br />[πŸ“–](https://github.com/renderedtext/render_async/commits?author=schneems "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/75705?v=4" width="100px;"/><br /><sub><b>Richard Venneman</b></sub>](https://www.cityspotters.com)<br />[πŸ“–](https://github.com/renderedtext/render_async/commits?author=richardvenneman "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/381395?v=4" width="100px;"/><br /><sub><b>Filipe W. Lima</b></sub>](https://github.com/filipewl)<br />[πŸ“–](https://github.com/renderedtext/render_async/commits?author=filipewl "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/3135638?v=4" width="100px;"/><br /><sub><b>JesΓΊs Eduardo Clemens Chong</b></sub>](https://github.com/eclemens)<br />[πŸ’»](https://github.com/renderedtext/render_async/commits?author=eclemens "Code") | [<img src="https://avatars3.githubusercontent.com/u/1935686?v=4" width="100px;"/><br /><sub><b>RenΓ© Klačan</b></sub>](https://github.com/reneklacan)<br />[πŸ’»](https://github.com/renderedtext/render_async/commits?author=reneklacan "Code") [πŸ“–](https://github.com/renderedtext/render_async/commits?author=reneklacan "Documentation") |
798
812
  | [<img src="https://avatars1.githubusercontent.com/u/1313442?v=4" width="100px;"/><br /><sub><b>Gil Gomes</b></sub>](http://gilgomes.com.br)<br />[πŸ“–](https://github.com/renderedtext/render_async/commits?author=gil27 "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/6081795?v=4" width="100px;"/><br /><sub><b>Khoa Nguyen</b></sub>](https://github.com/ThanhKhoaIT)<br />[πŸ’»](https://github.com/renderedtext/render_async/commits?author=ThanhKhoaIT "Code") [πŸ“–](https://github.com/renderedtext/render_async/commits?author=ThanhKhoaIT "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/8645918?v=4" width="100px;"/><br /><sub><b>Preet Sethi</b></sub>](https://www.linkedin.com/in/preetsethila/)<br />[πŸ’»](https://github.com/renderedtext/render_async/commits?author=preetsethi "Code") | [<img src="https://avatars3.githubusercontent.com/u/11586335?v=4" width="100px;"/><br /><sub><b>fangxing</b></sub>](https://github.com/fffx)<br />[πŸ’»](https://github.com/renderedtext/render_async/commits?author=fffx "Code") | [<img src="https://avatars3.githubusercontent.com/u/1191418?v=4" width="100px;"/><br /><sub><b>Emmanuel Pire</b></sub>](http://blog.lipsumarium.com)<br />[πŸ’»](https://github.com/renderedtext/render_async/commits?author=lipsumar "Code") [πŸ“–](https://github.com/renderedtext/render_async/commits?author=lipsumar "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/615509?v=4" width="100px;"/><br /><sub><b>Maxim Geerinck</b></sub>](https://github.com/maximgeerinck)<br />[πŸ’»](https://github.com/renderedtext/render_async/commits?author=maximgeerinck "Code") | [<img src="https://avatars1.githubusercontent.com/u/251706?v=4" width="100px;"/><br /><sub><b>Don</b></sub>](https://github.com/vanboom)<br />[πŸ’»](https://github.com/renderedtext/render_async/commits?author=vanboom "Code") |
799
813
  | [<img src="https://avatars0.githubusercontent.com/u/998682?v=4" width="100px;"/><br /><sub><b>villu164</b></sub>](https://github.com/villu164)<br />[πŸ“–](https://github.com/renderedtext/render_async/commits?author=villu164 "Documentation") | [<img src="https://avatars.githubusercontent.com/u/11203679?v=4" width="100px;"/><br /><sub><b>Mitchell Buckley</b></sub>](https://github.com/Mbuckley0)<br />[πŸ’»](https://github.com/renderedtext/render_async/commits?author=Mbuckley0 "Code") [πŸ“–](https://github.com/renderedtext/render_async/commits?author=Mbuckley0 "Documentation") | [<img src="https://avatars.githubusercontent.com/u/15371677?v=4" width="100px;"/><br /><sub><b>yhirano55</b></sub>](https://github.com/yhirano55)<br />[πŸ’»](https://github.com/renderedtext/render_async/commits?author=yhirano55 "Code") [πŸ“–](https://github.com/renderedtext/render_async/commits?author=yhirano55 "Documentation") |
800
814
  <!-- ALL-CONTRIBUTORS-LIST:END -->
@@ -18,6 +18,7 @@
18
18
  error_message: error_message,
19
19
  error_event_name: error_event_name,
20
20
  retry_count: retry_count,
21
+ retry_count_header: retry_count_header,
21
22
  retry_delay: retry_delay,
22
23
  interval: interval,
23
24
  turbolinks: RenderAsync.configuration.turbolinks,
@@ -39,9 +39,15 @@ if (window.jQuery) {
39
39
 
40
40
  function _makeRequest(currentRetryCount) {
41
41
  var headers = <%= headers.to_json.html_safe %>;
42
- var csrfTokenElement = document.querySelector('meta[name="csrf-token"]')
42
+ var csrfTokenElement = document.querySelector('meta[name="csrf-token"]');
43
43
  if (csrfTokenElement)
44
- headers['X-CSRF-Token'] = csrfTokenElement.content
44
+ headers['X-CSRF-Token'] = csrfTokenElement.content;
45
+
46
+ <% if retry_count_header %>
47
+ if (typeof(currentRetryCount) === 'number') {
48
+ headers['<%= retry_count_header.html_safe %>'] = currentRetryCount;
49
+ }
50
+ <% end %>
45
51
 
46
52
  $.ajax({
47
53
  url: '<%= path.html_safe %>',
@@ -100,6 +106,8 @@ if (window.jQuery) {
100
106
  _makeRequest(currentRetryCount)
101
107
  }, <%= retry_delay %>)
102
108
  }
109
+ <% else %>
110
+ _retryMakeRequest = _makeRequest
103
111
  <% end %>
104
112
 
105
113
  function retry(currentRetryCount) {
@@ -46,9 +46,15 @@
46
46
  request.open('<%= method %>', '<%= path.html_safe %>', asyncRequest);
47
47
 
48
48
  var headers = <%= headers.to_json.html_safe %>;
49
- var csrfTokenElement = document.querySelector('meta[name="csrf-token"]')
49
+ var csrfTokenElement = document.querySelector('meta[name="csrf-token"]');
50
50
  if (csrfTokenElement)
51
- headers['X-CSRF-Token'] = csrfTokenElement.content
51
+ headers['X-CSRF-Token'] = csrfTokenElement.content;
52
+
53
+ <% if retry_count_header %>
54
+ if (typeof(currentRetryCount) === 'number') {
55
+ headers['<%= retry_count_header.html_safe %>'] = currentRetryCount;
56
+ }
57
+ <% end %>
52
58
 
53
59
  Object.keys(headers).map(function(key) {
54
60
  request.setRequestHeader(key, headers[key]);
@@ -108,11 +114,13 @@
108
114
  <% if retry_count > 0 %>
109
115
 
110
116
  <% if retry_delay %>
111
- _retryMakeRequest = function(currentRetryCount) {
117
+ var _retryMakeRequest = function(currentRetryCount) {
112
118
  setTimeout(function() {
113
119
  _makeRequest(currentRetryCount)
114
120
  }, <%= retry_delay %>)
115
121
  }
122
+ <% else %>
123
+ var _retryMakeRequest = _makeRequest
116
124
  <% end %>
117
125
 
118
126
  function retry(currentRetryCount) {
@@ -1,3 +1,3 @@
1
1
  module RenderAsync
2
- VERSION = "2.1.10".freeze
2
+ VERSION = "2.1.11".freeze
3
3
  end
@@ -63,6 +63,7 @@ module RenderAsync
63
63
  def retry_options(options)
64
64
  {
65
65
  retry_count: options.delete(:retry_count) || 0,
66
+ retry_count_header: options.delete(:retry_count_header),
66
67
  retry_delay: options.delete(:retry_delay)
67
68
  }
68
69
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: render_async
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.10
4
+ version: 2.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Grubbe
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-03-21 00:00:00.000000000 Z
12
+ date: 2021-10-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake