view_component_reflex 3.2.0 → 3.3.1

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: 6b4bb28b771603fa4e792b0047b4553bd3fabc4f6bc57684b2ea78fc580ae645
4
- data.tar.gz: ace4315c83201693a8217aa3eab37d8e56aebb9e26a188e87c17879eccc98a5f
3
+ metadata.gz: 45cad5ecb337f55a9213805f7f4876f98d6677a7b8f9cb845e40eb427c0016ed
4
+ data.tar.gz: 662592a447ce78cac1c0d3b7ceb32a003f66d20bf5a16cd794eab0a476a5288f
5
5
  SHA512:
6
- metadata.gz: efa9e440ddafb686295047c3a613a22d9e50f2b4d493105ba9856e72bca2fea2a711bcea1ccf0d66c32e95b19f0f8a526f029f72470b1791730dc05eb0ed7beb
7
- data.tar.gz: 2c50c353ace6c579fe5c9a807605bcb85de103342547b407917592df41c819385567f5e533582f4ccaaeb9c7056ed30cc42d2a26df489e7c132ec5c846c58cc6
6
+ metadata.gz: 0037a5eb9513320b7be49f1e9d3607f50a5560c52240f399e9d965863df0de0e7b1eb038a1650f1d68c117f8e5b906a4085f6dd223206d41076f3961aaad4416
7
+ data.tar.gz: 87357055b74a8627f47f1e04cf2d4eaf1c9a7f4d99926579507a5e47af17c8229944975916e3cdff6a6742cf9cae2c9c57123ff8a74ab23d41d19f132eaf8d18
data/README.md CHANGED
@@ -309,8 +309,11 @@ end
309
309
  By default (since version `2.3.2`), view_component_reflex stores component state in session. You can optionally set the state adapter
310
310
  to use the memory by changing `config.state_adapter` to `ViewComponentReflex::StateAdapter::Memory`.
311
311
 
312
- Optionally, you can also store state right in the dom with `ViewComponentReflex::StateAdapter::Dom`. Not that the DOM
313
- adapter requires the `data-reflex-dataset="*"` property to be set on anything firing the reflex.
312
+ Optionally, you can also store state right in the dom with `ViewComponentReflex::StateAdapter::Dom`.
313
+ Note that the DOM adapter requires the `data-reflex-dataset="children"` property to be set on anything firing the reflex. You can mix it with other options like `data-reflex-dataset="ancestors children"`.
314
+ Optionally you can include all datasets in the reflex `data-reflex-dataset="*"` but in large applications you may want to limit the amount of data being transferred only to what is necessary.
315
+
316
+ When using the `ViewComponentReflex::StateAdapter::Dom` make sure your key does not contain underscores and is limited to max. 80 characters. That's important when you'd be using customized [collection_key](#collections) which increases the length of the key.
314
317
 
315
318
  ## Custom State Adapters
316
319
 
@@ -27,8 +27,8 @@ module ViewComponentReflex
27
27
  end
28
28
 
29
29
  def callbacks(key)
30
- @callbacks ||= {}
31
- @callbacks[key] ||= []
30
+ @@callbacks ||= {}
31
+ @@callbacks[key] ||= []
32
32
  end
33
33
 
34
34
  def register_callbacks(key)
@@ -11,6 +11,10 @@ module ViewComponentReflex
11
11
  Nokogiri::HTML(controller.response.body)
12
12
  end
13
13
 
14
+ def cable_ready
15
+ CableReady::Channels.instance[stream]
16
+ end
17
+
14
18
  def refresh!(primary_selector = nil, *rest)
15
19
  save_state
16
20
 
@@ -24,7 +28,7 @@ module ViewComponentReflex
24
28
  [primary_selector, *rest].each do |s|
25
29
  html = document.css(s)
26
30
  if html.present?
27
- CableReady::Channels.instance[stream].morph(
31
+ cable_ready.morph(
28
32
  selector: s,
29
33
  html: html.inner_html,
30
34
  children_only: true,
@@ -36,7 +40,7 @@ module ViewComponentReflex
36
40
  else
37
41
  refresh_component!
38
42
  end
39
- CableReady::Channels.instance[stream].broadcast
43
+ cable_ready.broadcast
40
44
  end
41
45
 
42
46
  def stream
@@ -60,7 +64,7 @@ module ViewComponentReflex
60
64
  end
61
65
 
62
66
  def refresh_component!
63
- CableReady::Channels.instance[stream].morph(
67
+ cable_ready.morph(
64
68
  selector: selector,
65
69
  children_only: true,
66
70
  html: component_document.css(selector).to_html,
@@ -187,7 +191,8 @@ module ViewComponentReflex
187
191
  :prevent_refresh!,
188
192
  :selector,
189
193
  :stimulate,
190
- :stream_to
194
+ :stream_to,
195
+ :cable_ready
191
196
  ]
192
197
  exposed_methods.each do |meth|
193
198
  @component.define_singleton_method(meth) do |*a|
@@ -1,3 +1,3 @@
1
1
  module ViewComponentReflex
2
- VERSION = '3.2.0'
2
+ VERSION = '3.3.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_component_reflex
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua LeBlanc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-21 00:00:00.000000000 Z
11
+ date: 2023-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  requirements: []
119
- rubygems_version: 3.3.26
119
+ rubygems_version: 3.4.10
120
120
  signing_key:
121
121
  specification_version: 4
122
122
  summary: Allow stimulus reflexes in a view component