actionview-component-live 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/models/action_view/component/live/subscriber.rb +12 -0
- data/app/views/live.html.erb +1 -1
- data/lib/actionview/component/live/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5d9ee7b0e0e6ba5944579205fa83b8cd6395300961a6aadb21109f4996c2249
|
4
|
+
data.tar.gz: c1f723856cbdab4c5483dcc2a1c1e70a9d68ca63755a204471a5081ca89450a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d42e1e42a023a32a9a8fdc792bbd2ca269a197c6e23ff3ffd753586d8f9fd400dac3daaf6f65226a5e919c8a80a493878067ce326c759590a04f430636e98fd
|
7
|
+
data.tar.gz: e3bf85ec702f630b6f50e5a5166b1ca0ac1ab1756151471c7e4d758cd9f57346658e0fc0575a79129c6e857299c2aa02cac983bfa258aae641eab1a46c5fae58
|
data/README.md
CHANGED
@@ -4,13 +4,25 @@ module ActionView
|
|
4
4
|
module Subscriber
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
|
+
def live_render!
|
8
|
+
@live_render = true
|
9
|
+
end
|
10
|
+
|
11
|
+
def live_render?
|
12
|
+
@live_render
|
13
|
+
end
|
14
|
+
|
7
15
|
class_methods do
|
8
16
|
def listen_to(name)
|
9
17
|
LiveUpdater.subscribe(name.to_s.classify, self)
|
10
18
|
end
|
11
19
|
end
|
12
20
|
|
21
|
+
# Used as view helper to wrap view in div that will connect to auto-updating stimulus controller
|
22
|
+
# If we render the component in live update on cable we will not wrap it - we just need the component content.
|
23
|
+
#
|
13
24
|
def live
|
25
|
+
return yield if live_render?
|
14
26
|
# <div data-controller="live" data-live-component="UserCardComponent" data-live-id="<%= id %>">
|
15
27
|
content_tag(:div, nil, data: {controller: :live, live_component: self.class.name, live_id: id}) { yield }
|
16
28
|
end
|
data/app/views/live.html.erb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
<%= render component
|
1
|
+
<%= render component.new(locals).tap(&:live_render!) %>
|