view_component_reflex 2.0.2 → 2.1.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 415195dd61211d392433d4e85963a6807871143f255b3264e2f7b4871bb42c42
|
4
|
+
data.tar.gz: 69f6030f02557d4d9886e3cfc00c738c66d748eb7a1a4b8149136ddaef8f8e9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e12ff695c21dc3f6c140c9d7aa7ccc854eeaeacf2a8071dc519f87c4ca1447464c01f8dfc9c200c0ac720dd864a71788fcc80f74072577c4c833743ccea29c79
|
7
|
+
data.tar.gz: ed7a85c244de733490571e7c4b529ce7b8dd295c0f6c1a5d57b15f40460b4a3737f2669bf8f28845d80a06b2ed721de49bc810c7ac9477629ead664635b2f2ee
|
data/README.md
CHANGED
@@ -108,6 +108,20 @@ def collection_key
|
|
108
108
|
end
|
109
109
|
```
|
110
110
|
|
111
|
+
### stimulate(target, data)
|
112
|
+
Stimulate another reflex from within your component. This typically requires the key of the component you're stimulating
|
113
|
+
which can be passed in via parameters.
|
114
|
+
|
115
|
+
```ruby
|
116
|
+
def initialize(parent_key)
|
117
|
+
@parent_key = parent_key
|
118
|
+
end
|
119
|
+
|
120
|
+
def stimulate_other
|
121
|
+
stimulate("OtherComponent#method", { key: @parent_key })
|
122
|
+
end
|
123
|
+
```
|
124
|
+
|
111
125
|
### refresh!(selectors)
|
112
126
|
Refresh a specific element on the page. Using this will implicitly run `prevent_render!`.
|
113
127
|
If you want to render a specific element, as well as the component, a common pattern would be to pass `selector` as one of the parameters
|
@@ -91,7 +91,11 @@ module ViewComponentReflex
|
|
91
91
|
else
|
92
92
|
initial_state = ViewComponentReflex::Engine.state_adapter.state(request, "#{@key}_initial")
|
93
93
|
ViewComponentReflex::Engine.state_adapter.state(request, @key).each do |k, v|
|
94
|
-
|
94
|
+
instance_value = instance_variable_get(k)
|
95
|
+
if permit_parameter?(initial_state[k], instance_value)
|
96
|
+
ViewComponentReflex::Engine.state_adapter.set_state(request, controller, "#{@key}_initial", { k => instance_value })
|
97
|
+
ViewComponentReflex::Engine.state_adapter.set_state(request, controller, @key, { k => instance_value })
|
98
|
+
else
|
95
99
|
instance_variable_set(k, v)
|
96
100
|
end
|
97
101
|
end
|
@@ -96,11 +96,23 @@ module ViewComponentReflex
|
|
96
96
|
component_class.stimulus_controller
|
97
97
|
end
|
98
98
|
|
99
|
+
def stimulate(target, data)
|
100
|
+
dataset = {}
|
101
|
+
data.each do |k, v|
|
102
|
+
dataset["data-#{k}"] = v.to_s
|
103
|
+
end
|
104
|
+
channel.receive({
|
105
|
+
"target" => target,
|
106
|
+
"attrs" => element.attributes.to_h.symbolize_keys,
|
107
|
+
"dataset" => dataset
|
108
|
+
})
|
109
|
+
end
|
110
|
+
|
99
111
|
def component
|
100
112
|
return @component if @component
|
101
113
|
@component = component_class.allocate
|
102
114
|
reflex = self
|
103
|
-
exposed_methods = [:params, :request, :element, :refresh!, :refresh_all!, :stimulus_controller, :session, :prevent_refresh!, :selector]
|
115
|
+
exposed_methods = [:params, :request, :element, :refresh!, :refresh_all!, :stimulus_controller, :session, :prevent_refresh!, :selector, :stimulate]
|
104
116
|
exposed_methods.each do |meth|
|
105
117
|
@component.define_singleton_method(meth) do |*a|
|
106
118
|
reflex.send(meth, *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: 2.0
|
4
|
+
version: 2.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: 2020-07-
|
11
|
+
date: 2020-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|