actionview-component-live 0.1.2 → 0.2.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: 9e3e1d0cee952a9a568c584e3107e4768de18e527b2edf4c4ef0fa209b037214
4
- data.tar.gz: d0072b8cb8ceab9868fb7f41eaf6c89b89397d627a96bdd8bb3b8f2c6f3b03b7
3
+ metadata.gz: f5d9ee7b0e0e6ba5944579205fa83b8cd6395300961a6aadb21109f4996c2249
4
+ data.tar.gz: c1f723856cbdab4c5483dcc2a1c1e70a9d68ca63755a204471a5081ca89450a6
5
5
  SHA512:
6
- metadata.gz: e4813db0c112a016b614375b0a0e58546eca9bf5a7d02b32833144e944c210facfc862216448c504154e114c601b537bd288a7c1113e6b74efb3ea44e99ee41e
7
- data.tar.gz: 2ddbde97aee21e9b659cf098b3a740551fa80dd8614adf2a9b9742bc0e05a92dd1ff3895e489ef2aad360768a1a115aa90276efe7a224a02afe369f2499e9472
6
+ metadata.gz: 8d42e1e42a023a32a9a8fdc792bbd2ca269a197c6e23ff3ffd753586d8f9fd400dac3daaf6f65226a5e919c8a80a493878067ce326c759590a04f430636e98fd
7
+ data.tar.gz: e3bf85ec702f630b6f50e5a5166b1ca0ac1ab1756151471c7e4d758cd9f57346658e0fc0575a79129c6e857299c2aa02cac983bfa258aae641eab1a46c5fae58
data/README.md CHANGED
@@ -60,7 +60,7 @@ $ bundle
60
60
 
61
61
  Add stimulus controller
62
62
  ```bash
63
- $ yarn add stimulus-actionview-live, '<0.1.0'
63
+ $ yarn add stimulus-actionview-live, '>=0.1.0'
64
64
  ```
65
65
 
66
66
  Add these 2 lines to your `app/javascript/controllers/index.js`
@@ -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
@@ -1 +1 @@
1
- <%= render component: component, locals: locals %>
1
+ <%= render component.new(locals).tap(&:live_render!) %>
@@ -1,7 +1,7 @@
1
1
  module Actionview
2
2
  module Component
3
3
  module Live
4
- VERSION = '0.1.2'
4
+ VERSION = '0.2.0'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionview-component-live
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Træls Ravn