stimulus_reflex 3.5.0.pre6 → 3.5.0.pre9

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 (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2 -1177
  3. data/Gemfile.lock +123 -100
  4. data/README.md +47 -6
  5. data/app/assets/javascripts/stimulus_reflex.js +969 -0
  6. data/app/assets/javascripts/stimulus_reflex.min.js +2 -0
  7. data/app/assets/javascripts/stimulus_reflex.min.js.map +1 -0
  8. data/app/assets/javascripts/stimulus_reflex.umd.js +904 -0
  9. data/app/assets/javascripts/stimulus_reflex.umd.min.js +905 -0
  10. data/app/assets/javascripts/stimulus_reflex.umd.min.js.map +1 -0
  11. data/app/channels/stimulus_reflex/channel.rb +21 -2
  12. data/lib/stimulus_reflex/broadcasters/nothing_broadcaster.rb +1 -0
  13. data/lib/stimulus_reflex/engine.rb +29 -0
  14. data/lib/stimulus_reflex/importmap.rb +4 -0
  15. data/lib/stimulus_reflex/open_struct_fix.rb +29 -0
  16. data/lib/stimulus_reflex/reflex.rb +10 -3
  17. data/lib/stimulus_reflex/reflex_data.rb +8 -0
  18. data/lib/stimulus_reflex/reflex_factory.rb +3 -1
  19. data/lib/stimulus_reflex/utils/logger.rb +2 -0
  20. data/lib/stimulus_reflex/utils/sanity_checker.rb +0 -58
  21. data/lib/stimulus_reflex/version.rb +1 -1
  22. data/lib/stimulus_reflex.rb +2 -6
  23. data/package.json +67 -0
  24. data/rollup.config.js +85 -0
  25. data/stimulus_reflex.gemspec +63 -0
  26. data/test/broadcasters/broadcaster_test_case.rb +1 -1
  27. data/test/broadcasters/nothing_broadcaster_test.rb +3 -1
  28. data/test/broadcasters/page_broadcaster_test.rb +4 -2
  29. data/test/broadcasters/selector_broadcaster_test.rb +12 -6
  30. data/test/callbacks_test.rb +23 -23
  31. data/test/reflex_test.rb +2 -2
  32. data/test/tmp/app/reflexes/application_reflex.rb +3 -10
  33. data/test/tmp/app/reflexes/{demo_reflex.rb → user_reflex.rb} +10 -2
  34. data/web-test-runner.config.mjs +12 -0
  35. data/yarn-error.log +4964 -0
  36. data/yarn.lock +4520 -0
  37. metadata +118 -38
  38. data/lib/generators/USAGE +0 -14
  39. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/%file_name%_controller.js.tt +0 -101
  40. data/lib/generators/stimulus_reflex/templates/app/javascript/controllers/application_controller.js.tt +0 -60
  41. data/lib/generators/stimulus_reflex/templates/app/reflexes/%file_name%_reflex.rb.tt +0 -41
  42. data/lib/generators/stimulus_reflex/templates/app/reflexes/application_reflex.rb.tt +0 -19
  43. data/lib/tasks/stimulus_reflex/install.rake +0 -116
data/rollup.config.js ADDED
@@ -0,0 +1,85 @@
1
+ import resolve from '@rollup/plugin-node-resolve'
2
+ import commonjs from '@rollup/plugin-commonjs'
3
+ import json from '@rollup/plugin-json'
4
+ import { terser } from 'rollup-plugin-terser'
5
+
6
+ const pretty = () => {
7
+ return terser({
8
+ mangle: false,
9
+ compress: false,
10
+ format: {
11
+ beautify: true,
12
+ indent_level: 2
13
+ }
14
+ })
15
+ }
16
+
17
+ const minify = () => {
18
+ return terser({
19
+ mangle: true,
20
+ compress: true
21
+ })
22
+ }
23
+
24
+ const esConfig = {
25
+ format: 'es',
26
+ inlineDynamicImports: true
27
+ }
28
+
29
+ const umdConfig = {
30
+ name: 'StimulusReflex',
31
+ format: 'umd',
32
+ exports: 'named',
33
+ globals: {
34
+ morphdom: 'morphdom',
35
+ cable_ready: 'CableReady',
36
+ '@hotwired/stimulus': 'Stimulus'
37
+ }
38
+ }
39
+
40
+ const distFolders = ['dist', 'app/assets/javascripts']
41
+
42
+ const output = distFolders
43
+ .map(distFolder => [
44
+ {
45
+ ...umdConfig,
46
+ file: `${distFolder}/stimulus_reflex.umd.js`,
47
+ plugins: [pretty()]
48
+ },
49
+ {
50
+ ...umdConfig,
51
+ file: `${distFolder}/stimulus_reflex.umd.min.js`,
52
+ sourcemap: true,
53
+ plugins: [pretty()]
54
+ },
55
+ {
56
+ ...esConfig,
57
+ file: `${distFolder}/stimulus_reflex.js`,
58
+ format: 'es',
59
+ plugins: [pretty()]
60
+ },
61
+ {
62
+ ...esConfig,
63
+ file: `${distFolder}/stimulus_reflex.min.js`,
64
+ sourcemap: true,
65
+ plugins: [minify()]
66
+ }
67
+ ])
68
+ .flat()
69
+
70
+ export default [
71
+ {
72
+ external: [
73
+ 'morphdom',
74
+ '@hotwired/stimulus',
75
+ 'cable_ready',
76
+ '@rails/actioncable'
77
+ ],
78
+ input: 'javascript/index.js',
79
+ output,
80
+ plugins: [commonjs(), resolve(), json()],
81
+ watch: {
82
+ include: 'javascript/**'
83
+ }
84
+ }
85
+ ]
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path("lib/stimulus_reflex/version", __dir__)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "stimulus_reflex"
7
+ gem.license = "MIT"
8
+ gem.version = StimulusReflex::VERSION
9
+ gem.authors = ["Nathan Hopkins"]
10
+ gem.email = ["natehop@gmail.com"]
11
+ gem.homepage = "https://github.com/stimulusreflex/stimulus_reflex"
12
+ gem.summary = "Build reactive applications with the Rails tooling you already know and love."
13
+ gem.post_install_message = <<~MESSAGE
14
+ Finish installation by running:
15
+
16
+ rake stimulus_reflex:install
17
+
18
+ Get support for StimulusReflex and CableReady on Discord:
19
+
20
+ https://discord.gg/stimulus-reflex
21
+
22
+ MESSAGE
23
+
24
+ gem.metadata = {
25
+ "bug_tracker_uri" => "https://github.com/stimulusreflex/stimulus_reflex/issues",
26
+ "changelog_uri" => "https://github.com/stimulusreflex/stimulus_reflex/CHANGELOG.md",
27
+ "documentation_uri" => "https://docs.stimulusreflex.com",
28
+ "homepage_uri" => gem.homepage,
29
+ "source_code_uri" => gem.homepage
30
+ }
31
+
32
+ gem.files = Dir[
33
+ "lib/**/*.rb",
34
+ "app/**/*.rb",
35
+ "app/assets/javascripts/*",
36
+ "bin/*",
37
+ "[A-Z]*"
38
+ ]
39
+
40
+ gem.test_files = Dir["test/**/*.rb"]
41
+
42
+ gem.required_ruby_version = ">= 2.7.0"
43
+
44
+ rails_version = ">= 5.2"
45
+ gem.add_dependency "actioncable", rails_version
46
+ gem.add_dependency "actionpack", rails_version
47
+ gem.add_dependency "actionview", rails_version
48
+ gem.add_dependency "activesupport", rails_version
49
+ gem.add_dependency "railties", rails_version
50
+
51
+ gem.add_dependency "cable_ready", ">= 5.0.0.pre9"
52
+ gem.add_dependency "nokogiri"
53
+ gem.add_dependency "rack"
54
+ gem.add_dependency "redis"
55
+
56
+ gem.add_development_dependency "bundler", "~> 2.0"
57
+ gem.add_development_dependency "mocha"
58
+ gem.add_development_dependency "pry"
59
+ gem.add_development_dependency "pry-nav"
60
+ gem.add_development_dependency "rails", rails_version
61
+ gem.add_development_dependency "rake"
62
+ gem.add_development_dependency "standardrb", "~> 1.0"
63
+ end
@@ -34,6 +34,6 @@ class StimulusReflex::BroadcasterTestCase < ActionCable::Channel::TestCase
34
34
  def connection.env
35
35
  @env ||= {}
36
36
  end
37
- @reflex = StimulusReflex::Reflex.new(subscribe, url: "https://test.stimulusreflex.com", client_attributes: {reflex_id: "666"})
37
+ @reflex = StimulusReflex::Reflex.new(subscribe, url: "https://test.stimulusreflex.com", client_attributes: {reflex_id: "666", version: StimulusReflex::VERSION})
38
38
  end
39
39
  end
@@ -11,6 +11,7 @@ class StimulusReflex::NothingBroadcasterTest < StimulusReflex::BroadcasterTestCa
11
11
  "operations" => [
12
12
  {
13
13
  "name" => "stimulus-reflex:morph-nothing",
14
+ "selector" => nil,
14
15
  "payload" => {},
15
16
  "stimulusReflex" => {
16
17
  "some" => "data",
@@ -19,7 +20,8 @@ class StimulusReflex::NothingBroadcasterTest < StimulusReflex::BroadcasterTestCa
19
20
  "reflexId" => "666",
20
21
  "operation" => "dispatchEvent"
21
22
  }
22
- ]
23
+ ],
24
+ "version" => CableReady::VERSION
23
25
  }
24
26
 
25
27
  assert_broadcast_on @reflex.stream_name, expected do
@@ -34,7 +34,8 @@ class StimulusReflex::PageBroadcasterTest < StimulusReflex::BroadcasterTestCase
34
34
  "reflexId" => "666",
35
35
  "operation" => "morph"
36
36
  }
37
- ]
37
+ ],
38
+ "version" => CableReady::VERSION
38
39
  }
39
40
 
40
41
  assert_broadcast_on @reflex.stream_name, expected do
@@ -67,7 +68,8 @@ class StimulusReflex::PageBroadcasterTest < StimulusReflex::BroadcasterTestCase
67
68
  "reflexId" => "666",
68
69
  "operation" => "morph"
69
70
  }
70
- ]
71
+ ],
72
+ "version" => CableReady::VERSION
71
73
  }
72
74
 
73
75
  assert_broadcast_on @reflex.stream_name, expected do
@@ -24,7 +24,8 @@ module StimulusReflex
24
24
  "reflexId" => "666",
25
25
  "operation" => "morph"
26
26
  }
27
- ]
27
+ ],
28
+ "version" => CableReady::VERSION
28
29
  }
29
30
 
30
31
  assert_broadcast_on @reflex.stream_name, expected do
@@ -50,7 +51,8 @@ module StimulusReflex
50
51
  "reflexId" => "666",
51
52
  "operation" => "innerHtml"
52
53
  }
53
- ]
54
+ ],
55
+ "version" => CableReady::VERSION
54
56
  }
55
57
 
56
58
  assert_broadcast_on @reflex.stream_name, expected do
@@ -76,7 +78,8 @@ module StimulusReflex
76
78
  "reflexId" => "666",
77
79
  "operation" => "innerHtml"
78
80
  }
79
- ]
81
+ ],
82
+ "version" => CableReady::VERSION
80
83
  }
81
84
 
82
85
  assert_broadcast_on @reflex.stream_name, expected do
@@ -102,7 +105,8 @@ module StimulusReflex
102
105
  "reflexId" => "666",
103
106
  "operation" => "innerHtml"
104
107
  }
105
- ]
108
+ ],
109
+ "version" => CableReady::VERSION
106
110
  }
107
111
 
108
112
  assert_broadcast_on @reflex.stream_name, expected do
@@ -128,7 +132,8 @@ module StimulusReflex
128
132
  "reflexId" => "666",
129
133
  "operation" => "innerHtml"
130
134
  }
131
- ]
135
+ ],
136
+ "version" => CableReady::VERSION
132
137
  }
133
138
 
134
139
  assert_broadcast_on @reflex.stream_name, expected do
@@ -156,7 +161,8 @@ module StimulusReflex
156
161
  "reflexId" => "666",
157
162
  "operation" => "morph"
158
163
  }
159
- ]
164
+ ],
165
+ "version" => CableReady::VERSION
160
166
  }
161
167
 
162
168
  assert_broadcast_on @reflex.stream_name, expected do
@@ -29,7 +29,7 @@ class CallbacksTest < ActionCable::Channel::TestCase
29
29
  end
30
30
  end
31
31
 
32
- reflex = BeforeCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment)
32
+ reflex = BeforeCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment, client_attributes: {version: StimulusReflex::VERSION})
33
33
  reflex.process(:increment)
34
34
  assert_equal 6, reflex.instance_variable_get("@count")
35
35
  end
@@ -45,7 +45,7 @@ class CallbacksTest < ActionCable::Channel::TestCase
45
45
  end
46
46
  end
47
47
 
48
- reflex = BeforeBlockCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment)
48
+ reflex = BeforeBlockCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment, client_attributes: {version: StimulusReflex::VERSION})
49
49
  reflex.process(:increment)
50
50
  assert_equal 6, reflex.instance_variable_get("@count")
51
51
  end
@@ -65,7 +65,7 @@ class CallbacksTest < ActionCable::Channel::TestCase
65
65
  end
66
66
  end
67
67
 
68
- reflex = AfterCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment)
68
+ reflex = AfterCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment, client_attributes: {version: StimulusReflex::VERSION})
69
69
  reflex.process(:increment)
70
70
  assert_equal 1, reflex.instance_variable_get("@count")
71
71
  end
@@ -81,7 +81,7 @@ class CallbacksTest < ActionCable::Channel::TestCase
81
81
  end
82
82
  end
83
83
 
84
- reflex = AfterBlockCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment)
84
+ reflex = AfterBlockCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment, client_attributes: {version: StimulusReflex::VERSION})
85
85
  reflex.process(:increment)
86
86
  assert_equal 1, reflex.instance_variable_get("@count")
87
87
  end
@@ -103,7 +103,7 @@ class CallbacksTest < ActionCable::Channel::TestCase
103
103
  end
104
104
  end
105
105
 
106
- reflex = AroundCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment)
106
+ reflex = AroundCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment, client_attributes: {version: StimulusReflex::VERSION})
107
107
  reflex.process(:increment)
108
108
  assert_equal 14, reflex.instance_variable_get("@count")
109
109
  end
@@ -131,7 +131,7 @@ class CallbacksTest < ActionCable::Channel::TestCase
131
131
  end
132
132
  end
133
133
 
134
- reflex = CallbackOrderReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment)
134
+ reflex = CallbackOrderReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment, client_attributes: {version: StimulusReflex::VERSION})
135
135
  reflex.process(:increment)
136
136
  assert_equal 3, reflex.instance_variable_get("@count")
137
137
  end
@@ -171,7 +171,7 @@ class CallbacksTest < ActionCable::Channel::TestCase
171
171
  end
172
172
  end
173
173
 
174
- reflex = IfCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment)
174
+ reflex = IfCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment, client_attributes: {version: StimulusReflex::VERSION})
175
175
  reflex.process(:increment)
176
176
  assert_equal 23, reflex.instance_variable_get("@count")
177
177
  end
@@ -203,7 +203,7 @@ class CallbacksTest < ActionCable::Channel::TestCase
203
203
  end
204
204
  end
205
205
 
206
- reflex = IfProcCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment)
206
+ reflex = IfProcCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment, client_attributes: {version: StimulusReflex::VERSION})
207
207
  reflex.process(:increment)
208
208
  assert_equal 23, reflex.instance_variable_get("@count")
209
209
  end
@@ -243,7 +243,7 @@ class CallbacksTest < ActionCable::Channel::TestCase
243
243
  end
244
244
  end
245
245
 
246
- reflex = UnlessCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment)
246
+ reflex = UnlessCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment, client_attributes: {version: StimulusReflex::VERSION})
247
247
  reflex.process(:increment)
248
248
  assert_equal 23, reflex.instance_variable_get("@count")
249
249
  end
@@ -275,7 +275,7 @@ class CallbacksTest < ActionCable::Channel::TestCase
275
275
  end
276
276
  end
277
277
 
278
- reflex = UnlessProcCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment)
278
+ reflex = UnlessProcCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment, client_attributes: {version: StimulusReflex::VERSION})
279
279
  reflex.process(:increment)
280
280
  assert_equal 23, reflex.instance_variable_get("@count")
281
281
  end
@@ -309,7 +309,7 @@ class CallbacksTest < ActionCable::Channel::TestCase
309
309
  end
310
310
  end
311
311
 
312
- reflex = OnlyCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :decrement)
312
+ reflex = OnlyCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :decrement, client_attributes: {version: StimulusReflex::VERSION})
313
313
  reflex.process(:decrement)
314
314
  assert_equal(-8, reflex.instance_variable_get("@count"))
315
315
  end
@@ -343,11 +343,11 @@ class CallbacksTest < ActionCable::Channel::TestCase
343
343
  end
344
344
  end
345
345
 
346
- reflex = ExceptCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment)
346
+ reflex = ExceptCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment, client_attributes: {version: StimulusReflex::VERSION})
347
347
  reflex.process(:increment)
348
348
  assert_equal 6, reflex.instance_variable_get("@count")
349
349
 
350
- reflex = ExceptCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :decrement)
350
+ reflex = ExceptCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :decrement, client_attributes: {version: StimulusReflex::VERSION})
351
351
  reflex.process(:decrement)
352
352
  assert_equal(-8, reflex.instance_variable_get("@count"))
353
353
  end
@@ -381,7 +381,7 @@ class CallbacksTest < ActionCable::Channel::TestCase
381
381
  end
382
382
  end
383
383
 
384
- reflex = SkipBeforeCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment)
384
+ reflex = SkipBeforeCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment, client_attributes: {version: StimulusReflex::VERSION})
385
385
  reflex.process(:increment)
386
386
  assert_equal 6, reflex.instance_variable_get("@count")
387
387
  end
@@ -415,7 +415,7 @@ class CallbacksTest < ActionCable::Channel::TestCase
415
415
  end
416
416
  end
417
417
 
418
- reflex = SkipAfterCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment)
418
+ reflex = SkipAfterCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment, client_attributes: {version: StimulusReflex::VERSION})
419
419
  reflex.process(:increment)
420
420
  assert_equal 1, reflex.instance_variable_get("@count")
421
421
  end
@@ -453,7 +453,7 @@ class CallbacksTest < ActionCable::Channel::TestCase
453
453
  end
454
454
  end
455
455
 
456
- reflex = SkipAroundCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment)
456
+ reflex = SkipAroundCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment, client_attributes: {version: StimulusReflex::VERSION})
457
457
  reflex.process(:increment)
458
458
  assert_equal 7, reflex.instance_variable_get("@count")
459
459
  end
@@ -482,7 +482,7 @@ class CallbacksTest < ActionCable::Channel::TestCase
482
482
  end
483
483
  end
484
484
 
485
- reflex = InheritedSkipApplicationReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment)
485
+ reflex = InheritedSkipApplicationReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment, client_attributes: {version: StimulusReflex::VERSION})
486
486
  reflex.process(:increment)
487
487
  assert_equal 6, reflex.instance_variable_get("@count")
488
488
  end
@@ -507,7 +507,7 @@ class CallbacksTest < ActionCable::Channel::TestCase
507
507
  end
508
508
  end
509
509
 
510
- reflex = SimplePrependBeforeCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment)
510
+ reflex = SimplePrependBeforeCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment, client_attributes: {version: StimulusReflex::VERSION})
511
511
  reflex.process(:increment)
512
512
  assert_equal 3, reflex.instance_variable_get("@count")
513
513
  end
@@ -527,7 +527,7 @@ class CallbacksTest < ActionCable::Channel::TestCase
527
527
  end
528
528
  end
529
529
 
530
- reflex = BlockPrependBeforeCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment)
530
+ reflex = BlockPrependBeforeCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment, client_attributes: {version: StimulusReflex::VERSION})
531
531
  reflex.process(:increment)
532
532
  assert_equal 3, reflex.instance_variable_get("@count")
533
533
  end
@@ -557,7 +557,7 @@ class CallbacksTest < ActionCable::Channel::TestCase
557
557
  end
558
558
  end
559
559
 
560
- reflex = InheritedPrependBeforeCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment)
560
+ reflex = InheritedPrependBeforeCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment, client_attributes: {version: StimulusReflex::VERSION})
561
561
  reflex.process(:increment)
562
562
  assert_equal 9, reflex.instance_variable_get("@count")
563
563
  end
@@ -586,7 +586,7 @@ class CallbacksTest < ActionCable::Channel::TestCase
586
586
  end
587
587
  end
588
588
 
589
- reflex = SimplePrependAroundCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment)
589
+ reflex = SimplePrependAroundCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment, client_attributes: {version: StimulusReflex::VERSION})
590
590
  reflex.process(:increment)
591
591
  assert_equal 26, reflex.instance_variable_get("@count")
592
592
  end
@@ -611,7 +611,7 @@ class CallbacksTest < ActionCable::Channel::TestCase
611
611
  end
612
612
  end
613
613
 
614
- reflex = SimplePrependAfterCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment)
614
+ reflex = SimplePrependAfterCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment, client_attributes: {version: StimulusReflex::VERSION})
615
615
  reflex.process(:increment)
616
616
  assert_equal 9, reflex.instance_variable_get("@count")
617
617
  end
@@ -643,7 +643,7 @@ class CallbacksTest < ActionCable::Channel::TestCase
643
643
  end
644
644
  end
645
645
 
646
- reflex = AppendCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment)
646
+ reflex = AppendCallbackReflex.new(subscribe, url: "https://test.stimulusreflex.com", method_name: :increment, client_attributes: {version: StimulusReflex::VERSION})
647
647
  reflex.process(:increment)
648
648
  assert_equal 25, reflex.instance_variable_get("@count")
649
649
  end
data/test/reflex_test.rb CHANGED
@@ -11,7 +11,7 @@ class StimulusReflex::ReflexTest < ActionCable::Channel::TestCase
11
11
  def connection.env
12
12
  @env ||= {}
13
13
  end
14
- @reflex = StimulusReflex::Reflex.new(subscribe, url: "https://test.stimulusreflex.com", client_attributes: {reflex_id: "666"})
14
+ @reflex = StimulusReflex::Reflex.new(subscribe, url: "https://test.stimulusreflex.com", client_attributes: {reflex_id: "666", version: StimulusReflex::VERSION})
15
15
  @reflex.controller_class.view_paths << Rails.root.join("test/views")
16
16
  end
17
17
 
@@ -33,7 +33,7 @@ class StimulusReflex::ReflexTest < ActionCable::Channel::TestCase
33
33
 
34
34
  test "params behave like ActionController::Parameters" do
35
35
  ActionDispatch::Request.any_instance.stubs(:parameters).returns({"a" => "1", "b" => "2", "c" => "3"})
36
- reflex = StimulusReflex::Reflex.new(subscribe, url: "https://test.stimulusreflex.com")
36
+ reflex = StimulusReflex::Reflex.new(subscribe, url: "https://test.stimulusreflex.com", client_attributes: {version: StimulusReflex::VERSION})
37
37
 
38
38
  deleted_param = reflex.params.delete("a")
39
39
 
@@ -3,17 +3,10 @@
3
3
  class ApplicationReflex < StimulusReflex::Reflex
4
4
  # Put application-wide Reflex behavior and callbacks in this file.
5
5
  #
6
- # Learn more at: https://docs.stimulusreflex.com/rtfm/reflex-classes
6
+ # Example:
7
7
  #
8
- # If your ActionCable connection is: `identified_by :current_user`
8
+ # # If your ActionCable connection is: `identified_by :current_user`
9
9
  # delegate :current_user, to: :connection
10
10
  #
11
- # If you need to localize your Reflexes, you can set the I18n locale here:
12
- #
13
- # before_reflex do
14
- # I18n.locale = :fr
15
- # end
16
- #
17
- # For code examples, considerations and caveats, see:
18
- # https://docs.stimulusreflex.com/rtfm/patterns#internationalization
11
+ # Learn more at: https://docs.stimulusreflex.com/rtfm/reflex-classes
19
12
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class DemoReflex < ApplicationReflex
3
+ class UserReflex < ApplicationReflex
4
4
  # Add Reflex methods in this file.
5
5
  #
6
6
  # All Reflex instances include CableReady::Broadcaster and expose the following properties:
@@ -17,7 +17,6 @@ class DemoReflex < ApplicationReflex
17
17
  # - unsigned - use an unsigned Global ID to map dataset attribute to a model eg. element.unsigned[:foo]
18
18
  # - cable_ready - a special cable_ready that can broadcast to the current visitor (no brackets needed)
19
19
  # - reflex_id - a UUIDv4 that uniquely identies each Reflex
20
- # - tab_id - a UUIDv4 that uniquely identifies the browser tab
21
20
  #
22
21
  # Example:
23
22
  #
@@ -32,4 +31,13 @@ class DemoReflex < ApplicationReflex
32
31
  # end
33
32
  #
34
33
  # Learn more at: https://docs.stimulusreflex.com/rtfm/reflex-classes
34
+
35
+ def update
36
+ end
37
+
38
+ def do_stuff
39
+ end
40
+
41
+ def do_more_stuff
42
+ end
35
43
  end
@@ -0,0 +1,12 @@
1
+ import rollupJson from '@rollup/plugin-json'
2
+ import { fromRollup } from '@web/dev-server-rollup'
3
+
4
+ const json = fromRollup(rollupJson)
5
+
6
+ export default {
7
+ nodeResolve: true,
8
+ mimeTypes: {
9
+ '**/*.json': 'js'
10
+ },
11
+ plugins: [json({})]
12
+ }