view_component_reflex 3.2.0 → 3.3.0

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: f83ad05fefd096a38658392650961db6eddc0bcd23597eb3b99dac0172461f8d
4
+ data.tar.gz: dfa368d0bd5ff81f66c42b03f81ea084302c1d150e82fccef5e74006ecaf967c
5
5
  SHA512:
6
- metadata.gz: efa9e440ddafb686295047c3a613a22d9e50f2b4d493105ba9856e72bca2fea2a711bcea1ccf0d66c32e95b19f0f8a526f029f72470b1791730dc05eb0ed7beb
7
- data.tar.gz: 2c50c353ace6c579fe5c9a807605bcb85de103342547b407917592df41c819385567f5e533582f4ccaaeb9c7056ed30cc42d2a26df489e7c132ec5c846c58cc6
6
+ metadata.gz: 1530f410f27aefa0ecf788dbac750f3772f86132e92a7cae5ca21846e0ded0e8e3cbf52b1c8aad3d3fbb8aee751da77998e6b67696be4dcc88cb96bd7dbbab48
7
+ data.tar.gz: ef01d4cfd26a466f0b009aca9f16ca91866c9d82a0076015b239fcf32b5132054ea6a557484cba9677d17adf43137ceed42b95cad7f60f728a45badbb632c5d3
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
 
@@ -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.0'
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.0
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-01-30 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.3.7
120
120
  signing_key:
121
121
  specification_version: 4
122
122
  summary: Allow stimulus reflexes in a view component