stimulus_reflex 3.4.0.pre1 → 3.4.0.pre6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of stimulus_reflex might be problematic. Click here for more details.

Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +95 -2
  3. data/Gemfile.lock +15 -15
  4. data/README.md +6 -10
  5. data/Rakefile +5 -5
  6. data/app/channels/stimulus_reflex/channel.rb +20 -4
  7. data/bin/console +1 -0
  8. data/bin/standardize +1 -1
  9. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/%file_name%_controller.js.tt +14 -2
  10. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt +10 -2
  11. data/lib/generators/stimulus_reflex/templates/app/reflexes/%file_name%_reflex.rb.tt +18 -9
  12. data/lib/generators/stimulus_reflex/templates/app/reflexes/application_reflex.rb.tt +2 -2
  13. data/lib/generators/stimulus_reflex/templates/config/initializers/stimulus_reflex.rb +13 -2
  14. data/lib/stimulus_reflex.rb +3 -0
  15. data/lib/stimulus_reflex/broadcasters/broadcaster.rb +11 -6
  16. data/lib/stimulus_reflex/broadcasters/nothing_broadcaster.rb +4 -0
  17. data/lib/stimulus_reflex/broadcasters/page_broadcaster.rb +7 -2
  18. data/lib/stimulus_reflex/broadcasters/selector_broadcaster.rb +12 -2
  19. data/lib/stimulus_reflex/cable_ready_channels.rb +18 -0
  20. data/lib/stimulus_reflex/configuration.rb +5 -2
  21. data/lib/stimulus_reflex/logger.rb +106 -0
  22. data/lib/stimulus_reflex/reflex.rb +9 -5
  23. data/lib/stimulus_reflex/sanity_checker.rb +60 -11
  24. data/lib/stimulus_reflex/utils/colorize.rb +23 -0
  25. data/lib/stimulus_reflex/version.rb +1 -1
  26. data/lib/tasks/stimulus_reflex/install.rake +3 -2
  27. data/package.json +11 -17
  28. data/stimulus_reflex.gemspec +1 -1
  29. data/tags +82 -41
  30. data/test/broadcasters/broadcaster_test.rb +10 -0
  31. data/test/broadcasters/broadcaster_test_case.rb +13 -0
  32. data/test/broadcasters/nothing_broadcaster_test.rb +33 -0
  33. data/test/broadcasters/page_broadcaster_test.rb +73 -0
  34. data/test/broadcasters/selector_broadcaster_test.rb +55 -0
  35. data/test/test_helper.rb +37 -0
  36. data/test/tmp/app/reflexes/application_reflex.rb +2 -2
  37. data/test/tmp/app/reflexes/demo_reflex.rb +34 -0
  38. data/yarn.lock +248 -1798
  39. metadata +23 -10
  40. data/test/tmp/app/reflexes/user_reflex.rb +0 -33
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96bccb8addb37f4a5096017acee725da0b9b85316216adf56e5591b582b337c5
4
- data.tar.gz: b7e3559981c86136e2db6f0a91eb7996cada8606c12eb23ab339220729bebb06
3
+ metadata.gz: 7c1b21d72db7dc3cae4b0a6225af2a17af6505e43b46d10a4db1ff1505566d1f
4
+ data.tar.gz: 0a0d7acc4ebaf2b9f717e0cf01f0cdcb2999694627f960cea27db10693b5480e
5
5
  SHA512:
6
- metadata.gz: fc0767685fc9cc55fce312f2112ec0b42682aeaae5200ca2f8b1371539e458cdfd55cf46335a22682a4fce50c851a9a996b7e12cf3caa4b12d3f309e3fb6ee4d
7
- data.tar.gz: f28b5af48c24bd07542e37ee5f940df373cc7f74a068c67dddfd8eda0f31a1131802bceaa69713f2f69235955e0b33a79fda1fed33cad66653158eb0e84c6654
6
+ metadata.gz: 92b7b673a36cea3d4bbbf3b491524a6f1819d5a7d477b0609bd605f236a24a4dc6a8c1ec9af336399a1179376c3e5257dd8266933607e45d183bb63220ddf1b8
7
+ data.tar.gz: baada4b0985537e8aed1717f383cde05c94bcd502e047d6a58bbbb50580a691960f1ff792c8cefbc07a0940c1541f0e1eea985be9193d345db92d99c0560a054
@@ -1,5 +1,95 @@
1
1
  # Changelog
2
2
 
3
+ ## [Unreleased](https://github.com/hopsoft/stimulus_reflex/tree/HEAD)
4
+
5
+ [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.4.0.pre5...HEAD)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - Update templates for new stage etc [\#390](https://github.com/hopsoft/stimulus_reflex/pull/390) ([leastbad](https://github.com/leastbad))
10
+ - reflexError and received refactor [\#389](https://github.com/hopsoft/stimulus_reflex/pull/389) ([leastbad](https://github.com/leastbad))
11
+ - add jQuery support to SR library events [\#388](https://github.com/hopsoft/stimulus_reflex/pull/388) ([leastbad](https://github.com/leastbad))
12
+ - dont exit in sanity checker on `stimulus\_reflex:install` [\#387](https://github.com/hopsoft/stimulus_reflex/pull/387) ([marcoroth](https://github.com/marcoroth))
13
+ - Allow `success` and `after` lifecycle methods on replaced elements [\#386](https://github.com/hopsoft/stimulus_reflex/pull/386) ([marcoroth](https://github.com/marcoroth))
14
+ - split SR operations from data.operations [\#385](https://github.com/hopsoft/stimulus_reflex/pull/385) ([leastbad](https://github.com/leastbad))
15
+ - don't show findElement warnings unless debugging [\#384](https://github.com/hopsoft/stimulus_reflex/pull/384) ([leastbad](https://github.com/leastbad))
16
+ - Setup a proxy object that wraps CableReady::Channels [\#382](https://github.com/hopsoft/stimulus_reflex/pull/382) ([hopsoft](https://github.com/hopsoft))
17
+ - non-SR cable\_ready operation pass-through [\#381](https://github.com/hopsoft/stimulus_reflex/pull/381) ([leastbad](https://github.com/leastbad))
18
+
19
+ ## [v3.4.0.pre5](https://github.com/hopsoft/stimulus_reflex/tree/v3.4.0.pre5) (2020-11-25)
20
+
21
+ [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.4.0.pre4...v3.4.0.pre5)
22
+
23
+ **Closed issues:**
24
+
25
+ - SR doesn't seem to handle redirects / 302s [\#376](https://github.com/hopsoft/stimulus_reflex/issues/376)
26
+
27
+ **Merged pull requests:**
28
+
29
+ - Move package.json to root of project [\#380](https://github.com/hopsoft/stimulus_reflex/pull/380) ([hopsoft](https://github.com/hopsoft))
30
+ - make element.reflexController a dictionary [\#379](https://github.com/hopsoft/stimulus_reflex/pull/379) ([existentialmutt](https://github.com/existentialmutt))
31
+ - fixed bug preventing callbacks for multiple morphs [\#378](https://github.com/hopsoft/stimulus_reflex/pull/378) ([leastbad](https://github.com/leastbad))
32
+ - Handles to mitigate race conditions when running reflexes in quick succession on the same element [\#377](https://github.com/hopsoft/stimulus_reflex/pull/377) ([existentialmutt](https://github.com/existentialmutt))
33
+ - Exit with nonzero status code [\#375](https://github.com/hopsoft/stimulus_reflex/pull/375) ([julianrubisch](https://github.com/julianrubisch))
34
+
35
+ ## [v3.4.0.pre4](https://github.com/hopsoft/stimulus_reflex/tree/v3.4.0.pre4) (2020-11-19)
36
+
37
+ [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.4.0.pre3...v3.4.0.pre4)
38
+
39
+ **Fixed bugs:**
40
+
41
+ - Fix fatal error in `stimulus\_reflex:install` task with Rails 5.2 [\#371](https://github.com/hopsoft/stimulus_reflex/pull/371) ([Matt-Yorkley](https://github.com/Matt-Yorkley))
42
+ - fix nothing morphs and error messages [\#368](https://github.com/hopsoft/stimulus_reflex/pull/368) ([leastbad](https://github.com/leastbad))
43
+
44
+ **Closed issues:**
45
+
46
+ - `stimulus\_reflex:install` fails to complete in Rails 5.2 [\#367](https://github.com/hopsoft/stimulus_reflex/issues/367)
47
+ - Form data still not captured [\#366](https://github.com/hopsoft/stimulus_reflex/issues/366)
48
+ - Console exception when reflex does not update a page that didn't trigger the reflex [\#363](https://github.com/hopsoft/stimulus_reflex/issues/363)
49
+ - Improve server-side logging options [\#264](https://github.com/hopsoft/stimulus_reflex/issues/264)
50
+
51
+ **Merged pull requests:**
52
+
53
+ - use puts instead of ActionCable.logger to sidestep silenced AC logs [\#373](https://github.com/hopsoft/stimulus_reflex/pull/373) ([leastbad](https://github.com/leastbad))
54
+ - Improve logged post\_install.js message [\#372](https://github.com/hopsoft/stimulus_reflex/pull/372) ([forsbergplustwo](https://github.com/forsbergplustwo))
55
+ - Pass additional reflex-related data to reflex from data [\#370](https://github.com/hopsoft/stimulus_reflex/pull/370) ([joshleblanc](https://github.com/joshleblanc))
56
+ - fix: rip out microbundle [\#369](https://github.com/hopsoft/stimulus_reflex/pull/369) ([ParamagicDev](https://github.com/ParamagicDev))
57
+ - Add tests for broadcasters [\#364](https://github.com/hopsoft/stimulus_reflex/pull/364) ([julianrubisch](https://github.com/julianrubisch))
58
+ - Do not run sanity check on `rails generate stimulus\_reflex:config` [\#362](https://github.com/hopsoft/stimulus_reflex/pull/362) ([RolandStuder](https://github.com/RolandStuder))
59
+ - fix: revert CR and @rails/actioncable to dependencies [\#361](https://github.com/hopsoft/stimulus_reflex/pull/361) ([ParamagicDev](https://github.com/ParamagicDev))
60
+ - xpath fix [\#360](https://github.com/hopsoft/stimulus_reflex/pull/360) ([leastbad](https://github.com/leastbad))
61
+
62
+ ## [v3.4.0.pre3](https://github.com/hopsoft/stimulus_reflex/tree/v3.4.0.pre3) (2020-11-11)
63
+
64
+ [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.4.0.pre2...v3.4.0.pre3)
65
+
66
+ **Merged pull requests:**
67
+
68
+ - Allow to supress warnings for sanity checks [\#359](https://github.com/hopsoft/stimulus_reflex/pull/359) ([RolandStuder](https://github.com/RolandStuder))
69
+ - serializeForm: only append given input if element is submit button [\#357](https://github.com/hopsoft/stimulus_reflex/pull/357) ([marcoroth](https://github.com/marcoroth))
70
+ - Update package.json to 3.4.0-pre2 [\#356](https://github.com/hopsoft/stimulus_reflex/pull/356) ([marcoroth](https://github.com/marcoroth))
71
+ - Fix elementToXPath import [\#355](https://github.com/hopsoft/stimulus_reflex/pull/355) ([julianrubisch](https://github.com/julianrubisch))
72
+ - Add guard clause to return valid empty form data [\#354](https://github.com/hopsoft/stimulus_reflex/pull/354) ([julianrubisch](https://github.com/julianrubisch))
73
+ - simplify xpath functions [\#353](https://github.com/hopsoft/stimulus_reflex/pull/353) ([leastbad](https://github.com/leastbad))
74
+ - pass reflex id to reflex [\#352](https://github.com/hopsoft/stimulus_reflex/pull/352) ([joshleblanc](https://github.com/joshleblanc))
75
+
76
+ ## [v3.4.0.pre2](https://github.com/hopsoft/stimulus_reflex/tree/v3.4.0.pre2) (2020-11-06)
77
+
78
+ [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.4.0.pre1...v3.4.0.pre2)
79
+
80
+ **Closed issues:**
81
+
82
+ - Regression in version 3.4.0-pre1: Cannot find module `cable\_ready` [\#350](https://github.com/hopsoft/stimulus_reflex/issues/350)
83
+
84
+ **Merged pull requests:**
85
+
86
+ - move `cable\_ready` to development dependencies [\#351](https://github.com/hopsoft/stimulus_reflex/pull/351) ([marcoroth](https://github.com/marcoroth))
87
+ - Fix serializeForm initialization [\#349](https://github.com/hopsoft/stimulus_reflex/pull/349) ([marcoroth](https://github.com/marcoroth))
88
+
89
+ ## [v3.4.0.pre1](https://github.com/hopsoft/stimulus_reflex/tree/v3.4.0.pre1) (2020-11-03)
90
+
91
+ [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.4.0.pre0...v3.4.0.pre1)
92
+
3
93
  ## [v3.4.0.pre0](https://github.com/hopsoft/stimulus_reflex/tree/v3.4.0.pre0) (2020-11-02)
4
94
 
5
95
  [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.3.0...v3.4.0.pre0)
@@ -180,7 +270,6 @@
180
270
  **Implemented enhancements:**
181
271
 
182
272
  - Returns more helpful error message if Reflex doesn't exist [\#254](https://github.com/hopsoft/stimulus_reflex/pull/254) ([leastbad](https://github.com/leastbad))
183
- - Update install.rake to handle Typescript [\#241](https://github.com/hopsoft/stimulus_reflex/pull/241) ([iv-mexx](https://github.com/iv-mexx))
184
273
  - Morph Modes: page, selector and nothing [\#211](https://github.com/hopsoft/stimulus_reflex/pull/211) ([leastbad](https://github.com/leastbad))
185
274
 
186
275
  **Fixed bugs:**
@@ -221,6 +310,10 @@
221
310
 
222
311
  [Full Changelog](https://github.com/hopsoft/stimulus_reflex/compare/v3.2.2...v3.2.3)
223
312
 
313
+ **Implemented enhancements:**
314
+
315
+ - Update install.rake to handle Typescript [\#241](https://github.com/hopsoft/stimulus_reflex/pull/241) ([iv-mexx](https://github.com/iv-mexx))
316
+
224
317
  **Fixed bugs:**
225
318
 
226
319
  - Add more smarts to \_\_perform [\#235](https://github.com/hopsoft/stimulus_reflex/pull/235) ([hopsoft](https://github.com/hopsoft))
@@ -334,7 +427,7 @@
334
427
 
335
428
  **Fixed bugs:**
336
429
 
337
- - Pluralize the generated class name, so that will match with the file name [\#178](https://github.com/hopsoft/stimulus_reflex/pull/178) ([darkrubyist](https://github.com/darkrubyist))
430
+ - Pluralize the generated class name, so that will match with the file name [\#178](https://github.com/hopsoft/stimulus_reflex/pull/178) ([dark88888](https://github.com/dark88888))
338
431
 
339
432
  **Closed issues:**
340
433
 
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stimulus_reflex (3.4.0.pre1)
5
- cable_ready (>= 4.3.0)
4
+ stimulus_reflex (3.4.0.pre6)
5
+ cable_ready (>= 4.4)
6
6
  nokogiri
7
7
  rack
8
8
  rails (>= 5.2)
@@ -68,17 +68,17 @@ GEM
68
68
  zeitwerk (~> 2.2, >= 2.2.2)
69
69
  ast (2.4.1)
70
70
  builder (3.2.4)
71
- cable_ready (4.3.0)
71
+ cable_ready (4.4.1)
72
72
  rails (>= 5.2)
73
73
  coderay (1.1.3)
74
74
  concurrent-ruby (1.1.7)
75
75
  crass (1.0.6)
76
- erubi (1.9.0)
76
+ erubi (1.10.0)
77
77
  globalid (0.4.2)
78
78
  activesupport (>= 4.2.0)
79
79
  i18n (1.8.5)
80
80
  concurrent-ruby (~> 1.0)
81
- loofah (2.7.0)
81
+ loofah (2.8.0)
82
82
  crass (~> 1.0.2)
83
83
  nokogiri (>= 1.5.9)
84
84
  mail (2.7.1)
@@ -93,7 +93,7 @@ GEM
93
93
  nio4r (2.5.4)
94
94
  nokogiri (1.10.10)
95
95
  mini_portile2 (~> 2.4.0)
96
- parallel (1.19.2)
96
+ parallel (1.20.1)
97
97
  parser (2.7.2.0)
98
98
  ast (~> 2.4.1)
99
99
  pry (0.12.2)
@@ -132,19 +132,19 @@ GEM
132
132
  thor (>= 0.20.3, < 2.0)
133
133
  rainbow (3.0.0)
134
134
  rake (13.0.1)
135
- redis (4.2.2)
136
- regexp_parser (1.8.2)
135
+ redis (4.2.5)
136
+ regexp_parser (2.0.0)
137
137
  rexml (3.2.4)
138
- rubocop (1.0.0)
138
+ rubocop (1.2.0)
139
139
  parallel (~> 1.10)
140
140
  parser (>= 2.7.1.5)
141
141
  rainbow (>= 2.2.2, < 4.0)
142
142
  regexp_parser (>= 1.8)
143
143
  rexml
144
- rubocop-ast (>= 0.6.0)
144
+ rubocop-ast (>= 1.0.1)
145
145
  ruby-progressbar (~> 1.7)
146
146
  unicode-display_width (>= 1.4.0, < 2.0)
147
- rubocop-ast (1.1.0)
147
+ rubocop-ast (1.2.0)
148
148
  parser (>= 2.7.1.5)
149
149
  rubocop-performance (1.8.1)
150
150
  rubocop (>= 0.87.0)
@@ -157,20 +157,20 @@ GEM
157
157
  actionpack (>= 4.0)
158
158
  activesupport (>= 4.0)
159
159
  sprockets (>= 3.0.0)
160
- standard (0.8.1)
161
- rubocop (= 1.0.0)
160
+ standard (0.9.0)
161
+ rubocop (= 1.2.0)
162
162
  rubocop-performance (= 1.8.1)
163
163
  standardrb (1.0.0)
164
164
  standard
165
165
  thor (1.0.1)
166
166
  thread_safe (0.3.6)
167
- tzinfo (1.2.7)
167
+ tzinfo (1.2.8)
168
168
  thread_safe (~> 0.1)
169
169
  unicode-display_width (1.7.0)
170
170
  websocket-driver (0.7.3)
171
171
  websocket-extensions (>= 0.1.0)
172
172
  websocket-extensions (0.1.5)
173
- zeitwerk (2.4.1)
173
+ zeitwerk (2.4.2)
174
174
 
175
175
  PLATFORMS
176
176
  ruby
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <p align="center">
2
- <img src="assets/stimulus-reflex-logo-with-copy.svg" width="360" />
2
+ <img src="https://gitcdn.link/repo/hopsoft/stimulus_reflex/master/assets/stimulus-reflex-logo-with-copy.svg" width="360" />
3
3
  <h1 align="center">Welcome to StimulusReflex 👋</h1>
4
4
  <p align="center">
5
5
  <img src="https://img.shields.io/gem/v/stimulus_reflex.svg?color=red" />
@@ -11,7 +11,7 @@
11
11
  <img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-brightgreen.svg" target="_blank" />
12
12
  </a>
13
13
  <a href="http://blog.codinghorror.com/the-best-code-is-no-code-at-all/" target="_blank">
14
- <img alt="Lines of Code" src="https://img.shields.io/badge/lines_of_code-1322-brightgreen.svg?style=flat" />
14
+ <img alt="Lines of Code" src="https://img.shields.io/badge/lines_of_code-1599-brightgreen.svg?style=flat" />
15
15
  </a>
16
16
  <a href="https://docs.stimulusreflex.com/" target="_blank">
17
17
  <img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" />
@@ -30,9 +30,6 @@
30
30
  <a href="https://www.codacy.com/manual/hopsoft/stimulus_reflex/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=hopsoft/stimulus_reflex&amp;utm_campaign=Badge_Grade" target="_blank">
31
31
  <img alt="Code Quality" src="https://app.codacy.com/project/badge/Grade/d1d72a7060f5467b8696884351cf477f"/>
32
32
  </a>
33
- <a href="https://codeclimate.com/github/hopsoft/stimulus_reflex/maintainability" target="_blank">
34
- <img alt="Maintainability" src="https://api.codeclimate.com/v1/badges/2b24fdbd1ae37a24bedb/maintainability" />
35
- </a>
36
33
  <a target="_blank" rel="noopener noreferrer" href="https://github.com/hopsoft/stimulus_reflex/workflows/Prettier-Standard/badge.svg">
37
34
  <img src="https://github.com/hopsoft/stimulus_reflex/workflows/Prettier-Standard/badge.svg" alt="Prettier-Standard" style="max-width:100%;">
38
35
  </a>
@@ -54,7 +51,7 @@ And, it's fast.
54
51
 
55
52
  It works seamlessly with the Rails tooling you already know and love.
56
53
 
57
- - Server-rendered HTML, delivered in miliseconds over the wire via Websockets
54
+ - Server-rendered HTML, delivered in milliseconds over the wire via Websockets
58
55
  - ERB templates and partials, with first-class [ViewComponent](https://github.com/github/view_component) support
59
56
  - [Russian doll caching](https://edgeguides.rubyonrails.org/caching_with_rails.html#russian-doll-caching) and [ActiveJob](https://guides.rubyonrails.org/active_job_basics.html)
60
57
  - [StimulusJS](https://stimulusjs.org/) and [Turbolinks](https://www.youtube.com/watch?v=SWEts0rlezA)
@@ -77,7 +74,7 @@ This project strives to live up to the vision outlined in [The Rails Doctrine](h
77
74
 
78
75
  ## 👩‍👩‍👧 Discord Community
79
76
 
80
- Please join over 600 of us on [Discord](https://discord.gg/XveN625) for support getting started, as well as active discussions around Rails, StimulusJS and CableReady.
77
+ Please join over 800 of us on [Discord](https://discord.gg/XveN625) for support getting started, as well as active discussions around Rails, StimulusJS and CableReady.
81
78
 
82
79
  ![](https://img.shields.io/discord/629472241427415060)
83
80
 
@@ -113,9 +110,8 @@ View the [wiki](https://github.com/hopsoft/stimulus_reflex/wiki/Editor-Configura
113
110
  1. Bump version number at `lib/stimulus_reflex/version.rb`
114
111
  1. Run `rake build`
115
112
  1. Run `rake release`
116
- 1. Change directories `cd ./javascript`
117
- 1. Run `yarn publish` - NOTE: this will throw a fatal error because the tag already exists but the package will still publish
118
-
113
+ 1. Run `yarn publish --no-git-tag-version`
114
+ 1. Commit and push changes to the `package.json` file
119
115
 
120
116
  ## 📝 License
121
117
 
data/Rakefile CHANGED
@@ -3,13 +3,13 @@
3
3
  require "bundler/gem_tasks"
4
4
  require "rails/test_unit/runner"
5
5
 
6
- task default: [:test]
7
-
8
- task :test do |task|
9
- return 1 unless system("cd javascript && yarn run test")
10
- Rails::TestUnit::Runner.run
6
+ task :test_javascript do |task|
7
+ system "yarn run test"
11
8
  end
12
9
 
13
10
  task :test_ruby do |task|
14
11
  Rails::TestUnit::Runner.run
15
12
  end
13
+
14
+ task test: [:test_javascript, :test_ruby]
15
+ task default: [:test]
@@ -32,7 +32,19 @@ class StimulusReflex::Channel < StimulusReflex.configuration.parent_channel.cons
32
32
  begin
33
33
  begin
34
34
  reflex_class = reflex_name.constantize.tap { |klass| raise ArgumentError.new("#{reflex_name} is not a StimulusReflex::Reflex") unless is_reflex?(klass) }
35
- reflex = reflex_class.new(self, url: url, element: element, selectors: selectors, method_name: method_name, permanent_attribute_name: permanent_attribute_name, params: params)
35
+ reflex = reflex_class.new(self,
36
+ url: url,
37
+ element: element,
38
+ selectors: selectors,
39
+ method_name: method_name,
40
+ params: params,
41
+ client_attributes: {
42
+ reflex_id: data["reflexId"],
43
+ xpath: data["xpath"],
44
+ c_xpath: data["cXpath"],
45
+ reflex_controller: data["reflexController"],
46
+ permanent_attribute_name: permanent_attribute_name
47
+ })
36
48
  delegate_call_to_reflex reflex, method_name, arguments
37
49
  rescue => invoke_error
38
50
  message = exception_message_with_backtrace(invoke_error)
@@ -41,7 +53,7 @@ class StimulusReflex::Channel < StimulusReflex.configuration.parent_channel.cons
41
53
  reflex.rescue_with_handler(invoke_error)
42
54
  reflex.broadcast_message subject: "error", body: body, data: data, error: invoke_error
43
55
  else
44
- logger.error "\e[31m#{body}\e[0m"
56
+ puts "\e[31m#{body}\e[0m"
45
57
  end
46
58
  return
47
59
  end
@@ -56,10 +68,14 @@ class StimulusReflex::Channel < StimulusReflex.configuration.parent_channel.cons
56
68
  message = exception_message_with_backtrace(render_error)
57
69
  body = "Reflex failed to re-render: #{message} [#{url}]"
58
70
  reflex.broadcast_message subject: "error", body: body, data: data, error: render_error
71
+ puts "\e[31m#{body}\e[0m"
59
72
  end
60
73
  end
61
74
  ensure
62
- commit_session reflex if reflex
75
+ if reflex
76
+ commit_session(reflex)
77
+ reflex.logger.print
78
+ end
63
79
  end
64
80
  end
65
81
 
@@ -94,7 +110,7 @@ class StimulusReflex::Channel < StimulusReflex.configuration.parent_channel.cons
94
110
  store.commit_session reflex.request, reflex.controller.response
95
111
  rescue => e
96
112
  message = "Failed to commit session! #{exception_message_with_backtrace(e)}"
97
- logger.error "\e[31m#{message}\e[0m"
113
+ puts "\e[31m#{message}\e[0m"
98
114
  end
99
115
 
100
116
  def exception_message_with_backtrace(exception)
@@ -4,4 +4,5 @@ require "bundler/setup"
4
4
  require "stimulus_reflex"
5
5
  require "pry"
6
6
 
7
+ StimulusReflex.configuration.parent_channel = "ActionCable::Channel::Base"
7
8
  Pry.start
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
3
  bundle exec standardrb --fix
4
- cd ./javascript && yarn run prettier-standard:format
4
+ yarn run prettier-standard:format
@@ -56,12 +56,20 @@ export default class extends ApplicationController {
56
56
  // }
57
57
 
58
58
  // danceSuccess(element, reflex, noop, reflexId) {
59
- // element.innerText = 'Danced like no one was watching! Was someone watching?'
59
+ // element.innerText = '\nDanced like no one was watching! Was someone watching?'
60
60
  // }
61
61
 
62
62
  // danceError(element, reflex, error, reflexId) {
63
63
  // console.error('danceError', error);
64
- // element.innerText = "Couldn't dance!"
64
+ // element.innerText = "\nCouldn\'t dance!"
65
+ // }
66
+
67
+ // afterDance(element, reflex, noop, reflexId) {
68
+ // element.innerText = '\nWhatever that was, it\'s over now.'
69
+ // }
70
+
71
+ // finalizeDance(element, reflex, noop, reflexId) {
72
+ // element.innerText = '\nNow, the cleanup can begin!'
65
73
  // }
66
74
  <% end -%>
67
75
  <% actions.each do |action| -%>
@@ -84,6 +92,10 @@ export default class extends ApplicationController {
84
92
  // <%= "after_#{action}".camelize(:lower) %>(element, reflex, noop, reflexId) {
85
93
  // console.log("after <%= action %>", element, reflex, reflexId)
86
94
  // }
95
+
96
+ // <%= "finalize_#{action}".camelize(:lower) %>(element, reflex, noop, reflexId) {
97
+ // console.log("finalize <%= action %>", element, reflex, reflexId)
98
+ // }
87
99
  <%= "\n" unless action == actions.last -%>
88
100
  <% end -%>
89
101
  }
@@ -39,14 +39,22 @@ export default class extends Controller {
39
39
  }
40
40
 
41
41
  reflexSuccess (element, reflex, noop, reflexId) {
42
- // show success message etc...
42
+ // show success message
43
43
  }
44
44
 
45
45
  reflexError (element, reflex, error, reflexId) {
46
- // show error message etc...
46
+ // show error message
47
+ }
48
+
49
+ reflexHalted (element, reflex, error, reflexId) {
50
+ // handle aborted Reflex action
47
51
  }
48
52
 
49
53
  afterReflex (element, reflex, noop, reflexId) {
50
54
  // document.body.classList.remove('wait')
51
55
  }
56
+
57
+ finalizeReflex (element, reflex, noop, reflexId) {
58
+ // all operations have completed, animation etc is now safe
59
+ }
52
60
  }
@@ -3,24 +3,33 @@
3
3
  class <%= class_name %>Reflex < ApplicationReflex
4
4
  # Add Reflex methods in this file.
5
5
  #
6
- # All Reflex instances expose the following properties:
6
+ # All Reflex instances include CableReady::Broadcaster and expose the following properties:
7
7
  #
8
- # - connection - the ActionCable connection
9
- # - channel - the ActionCable channel
10
- # - request - an ActionDispatch::Request proxy for the socket connection
11
- # - session - the ActionDispatch::Session store for the current visitor
12
- # - url - the URL of the page that triggered the reflex
13
- # - element - a Hash like object that represents the HTML element that triggered the reflex
14
- # - params - parameters from the element's closest form (if any)
8
+ # - connection - the ActionCable connection
9
+ # - channel - the ActionCable channel
10
+ # - request - an ActionDispatch::Request proxy for the socket connection
11
+ # - session - the ActionDispatch::Session store for the current visitor
12
+ # - flash - the ActionDispatch::Flash::FlashHash for the current request
13
+ # - url - the URL of the page that triggered the reflex
14
+ # - params - parameters from the element's closest form (if any)
15
+ # - element - a Hash like object that represents the HTML element that triggered the reflex
16
+ # - signed - use a signed Global ID to map dataset attribute to a model eg. element.signed[:foo]
17
+ # - unsigned - use an unsigned Global ID to map dataset attribute to a model eg. element.unsigned[:foo]
18
+ # - cable_ready - a special cable_ready that can broadcast to the current visitor (no brackets needed)
15
19
  #
16
20
  # Example:
17
21
  #
22
+ # before_reflex do
23
+ # # throw :abort # this will prevent the Reflex from continuing
24
+ # # learn more about callbacks at https://docs.stimulusreflex.com/lifecycle
25
+ # end
26
+ #
18
27
  # def example(argument=true)
19
28
  # # Your logic here...
20
29
  # # Any declared instance variables will be made available to the Rails controller and view.
21
30
  # end
22
31
  #
23
- # Learn more at: https://docs.stimulusreflex.com
32
+ # Learn more at: https://docs.stimulusreflex.com/reflexes#reflex-classes
24
33
 
25
34
  <% actions.each do |action| -%>
26
35
  def <%= action %>