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 +4 -4
- data/README.md +5 -2
- data/lib/view_component_reflex/component.rb +2 -2
- data/lib/view_component_reflex/reflex.rb +9 -4
- data/lib/view_component_reflex/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45cad5ecb337f55a9213805f7f4876f98d6677a7b8f9cb845e40eb427c0016ed
|
4
|
+
data.tar.gz: 662592a447ce78cac1c0d3b7ceb32a003f66d20bf5a16cd794eab0a476a5288f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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`.
|
313
|
-
adapter requires the `data-reflex-dataset="
|
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
|
-
|
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
|
-
|
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
|
-
|
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|
|
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.
|
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:
|
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.
|
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
|