view_component_reflex 3.0.6.pre.1 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/lib/view_component_reflex/reflex.rb +10 -2
- data/lib/view_component_reflex/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c044811ae2dc2de577c5d2c358bc47717c6db79e833537ffe30912b1324ed67e
|
4
|
+
data.tar.gz: 776a2f724d7b32dbf742bbaf3a7ffb14755767f01c13702313b5cf6f40950e4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b941db2658a7764e881383582d5244855dd09f8ec336d20165c07a9d9104d2ece87e0a4309f91b293f4329e70f0b22019f8fe8e31469dd3edb26519ff6d575b2
|
7
|
+
data.tar.gz: 3180e0b52a0709ecba31fc9200d5265646b8149d8e10ec45a674cf87d229a7bb706663edda3ad06a1a0cc22c707b570daea15c4ae58779c9e430e12d189a894f
|
data/README.md
CHANGED
@@ -176,6 +176,17 @@ def do_some_global_action
|
|
176
176
|
end
|
177
177
|
```
|
178
178
|
|
179
|
+
### stream_to(channel)
|
180
|
+
Stream to a custom channel, rather than the default stimulus reflex one
|
181
|
+
|
182
|
+
```ruby
|
183
|
+
def do_something
|
184
|
+
stream_to MyChannel
|
185
|
+
|
186
|
+
@foo = :bar
|
187
|
+
end
|
188
|
+
```
|
189
|
+
|
179
190
|
### key
|
180
191
|
This is a key unique to a particular component. It's used to reconcile state between renders, and should be passed as a data attribute whenever a reflex is called
|
181
192
|
|
@@ -19,7 +19,7 @@ module ViewComponentReflex
|
|
19
19
|
[primary_selector, *rest].each do |s|
|
20
20
|
html = document.css(s)
|
21
21
|
if html.present?
|
22
|
-
CableReady::Channels.instance[
|
22
|
+
CableReady::Channels.instance[stream].morph(
|
23
23
|
selector: s,
|
24
24
|
html: html.inner_html,
|
25
25
|
children_only: true,
|
@@ -34,6 +34,14 @@ module ViewComponentReflex
|
|
34
34
|
cable_ready.broadcast
|
35
35
|
end
|
36
36
|
|
37
|
+
def stream
|
38
|
+
@stream ||= stream_name
|
39
|
+
end
|
40
|
+
|
41
|
+
def stream_to(channel)
|
42
|
+
@stream = channel
|
43
|
+
end
|
44
|
+
|
37
45
|
def refresh_component!
|
38
46
|
component.tap do |k|
|
39
47
|
k.define_singleton_method(:key) do
|
@@ -41,7 +49,7 @@ module ViewComponentReflex
|
|
41
49
|
end
|
42
50
|
end
|
43
51
|
document = Nokogiri::HTML(component.render_in(controller.view_context))
|
44
|
-
CableReady::Channels.instance[
|
52
|
+
CableReady::Channels.instance[stream].morph(
|
45
53
|
selector: selector,
|
46
54
|
children_only: true,
|
47
55
|
html: document.css(selector).inner_html,
|
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.0
|
4
|
+
version: 3.1.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: 2021-01-
|
11
|
+
date: 2021-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -108,9 +108,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
108
|
version: '0'
|
109
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
110
|
requirements:
|
111
|
-
- - "
|
111
|
+
- - ">="
|
112
112
|
- !ruby/object:Gem::Version
|
113
|
-
version:
|
113
|
+
version: '0'
|
114
114
|
requirements: []
|
115
115
|
rubygems_version: 3.0.3
|
116
116
|
signing_key:
|