view_component_reflex 0.2.0 → 0.2.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 +1 -2
- data/lib/view_component_reflex.rb +10 -1
- data/lib/view_component_reflex/engine.rb +0 -1
- data/lib/view_component_reflex/version.rb +1 -1
- metadata +1 -2
- data/lib/stimulus_reflex/channel.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81ad30d3c12022e55c857cfc03487e06ed18522ffcaaae123d8f6e8a6c778677
|
4
|
+
data.tar.gz: c976d4533673254f126579ab91f0c9f808c82ff8d8e7ba9c38c6826a22e3c2ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12064756297206323014293e7fe801fe501754c0506f6f7afed4e2fc551293169e63efadc7e90cc410154c7ad16c15ae8328728121808e152398d5536bbeb4ce
|
7
|
+
data.tar.gz: 4c7149d348dacc75b239f44098dd8d08b7f9899884bdc879ed67bde8f53f4d3d6d547d3576a092c7fa62dfb3209059d89480db710c49eb13014a1bd0832bdec7
|
data/README.md
CHANGED
@@ -21,7 +21,7 @@ In addition to calling reflexes, there is a rudimentary state system. You can in
|
|
21
21
|
|
22
22
|
You can access state with the `state` helper. See the code below for an example.
|
23
23
|
|
24
|
-
If you're using state
|
24
|
+
If you're using state add `data-key="<%= key %>"` to any html element using a reflex. This
|
25
25
|
lets ViewComponentReflex keep track of which state belongs to which component.
|
26
26
|
|
27
27
|
|
@@ -30,7 +30,6 @@ lets ViewComponentReflex keep track of which state belongs to which component.
|
|
30
30
|
class CounterComponent < ViewComponentReflex::Component
|
31
31
|
|
32
32
|
def initialize
|
33
|
-
super()
|
34
33
|
initialize_state({
|
35
34
|
count: 0
|
36
35
|
})
|
@@ -1,7 +1,16 @@
|
|
1
1
|
require "view_component_reflex/engine"
|
2
2
|
require 'stimulus_reflex'
|
3
|
-
require_relative 'stimulus_reflex/channel'
|
4
3
|
|
5
4
|
module ViewComponentReflex
|
6
5
|
# Your code goes here...
|
7
6
|
end
|
7
|
+
|
8
|
+
class StimulusReflex::Channel < ActionCable::Channel::Base
|
9
|
+
def render_page_and_broadcast_morph(reflex, selectors, data = {})
|
10
|
+
html = render_page(reflex)
|
11
|
+
if reflex.respond_to? :stimulus_controller
|
12
|
+
selectors = ["[data-controller=\"#{reflex.stimulus_controller}\"]"]
|
13
|
+
end
|
14
|
+
broadcast_morphs selectors, data, html if html.present?
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: view_component_reflex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua LeBlanc
|
@@ -69,7 +69,6 @@ files:
|
|
69
69
|
- README.md
|
70
70
|
- Rakefile
|
71
71
|
- app/components/view_component_reflex/component.rb
|
72
|
-
- lib/stimulus_reflex/channel.rb
|
73
72
|
- lib/view_component_reflex.rb
|
74
73
|
- lib/view_component_reflex/engine.rb
|
75
74
|
- lib/view_component_reflex/version.rb
|
@@ -1,9 +0,0 @@
|
|
1
|
-
class StimulusReflex::Channel < ActionCable::Channel::Base
|
2
|
-
def render_page_and_broadcast_morph(reflex, selectors, data = {})
|
3
|
-
html = render_page(reflex)
|
4
|
-
if reflex.respond_to? :stimulus_controller
|
5
|
-
selectors = ["[data-controller=\"#{reflex.stimulus_controller}\"]"]
|
6
|
-
end
|
7
|
-
broadcast_morphs selectors, data, html if html.present?
|
8
|
-
end
|
9
|
-
end
|