actionview-component-live 0.1.1 → 0.1.2

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: def35d5369fafa73e5bb2fa052071dc0c1220fd532f6e10d70ce2fb3a677ca77
4
- data.tar.gz: 02df85d47f2f2cebf16731943b7e6e0d0574697dc4288e757d0a781b1be79520
3
+ metadata.gz: 9e3e1d0cee952a9a568c584e3107e4768de18e527b2edf4c4ef0fa209b037214
4
+ data.tar.gz: d0072b8cb8ceab9868fb7f41eaf6c89b89397d627a96bdd8bb3b8f2c6f3b03b7
5
5
  SHA512:
6
- metadata.gz: '0967d899598e4a259f13f7851e508be036fc67427f30e9c8f8219dd64e33049e2b1e04ea34535afbbd66e95d1da9e5ee823acdbc580a0818c31377c7bd5eb6e7'
7
- data.tar.gz: e3f54d22ff49be4cd1dd86e089dc6ce57b37f910f5a7c38adf5874e6094d5c6bcd7a257fc67e05f6fca359651162721b3d16dcc8902f2420843c417aa5d5bb8e
6
+ metadata.gz: e4813db0c112a016b614375b0a0e58546eca9bf5a7d02b32833144e944c210facfc862216448c504154e114c601b537bd288a7c1113e6b74efb3ea44e99ee41e
7
+ data.tar.gz: 2ddbde97aee21e9b659cf098b3a740551fa80dd8614adf2a9b9742bc0e05a92dd1ff3895e489ef2aad360768a1a115aa90276efe7a224a02afe369f2499e9472
data/README.md CHANGED
@@ -29,12 +29,12 @@ end
29
29
 
30
30
  **Important!** There is a strict naming requirement on the `listen_to` part and named argument in initialize!
31
31
 
32
- Then the component view. The view that should be auto updated must be wrapped in a element that attaches to a Stimulus controller called LiveController.
33
- It needs the name of the component and the id of the object that it is attached to.
32
+ Then the component view.
33
+ Notice the **=** on the live block. It wraps the view in a **div** tag so we know what part of the page to update.
34
34
  ```erb
35
- <div data-controller="live" data-live-component="MiniBasketComponent" data-live-id="<%= id %>">
35
+ <%= live do %>
36
36
  <b><%= count %> products in basket</b>
37
- </div>
37
+ <% end %>
38
38
  ```
39
39
 
40
40
  Finally we need to tell our DraftOrder to broadcast changes.
@@ -60,7 +60,7 @@ $ bundle
60
60
 
61
61
  Add stimulus controller
62
62
  ```bash
63
- $ yarn add stimulus-actionview-live
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`
@@ -81,7 +81,6 @@ The gem is available as open source under the terms of the [MIT License](https:/
81
81
  ## Nice to have
82
82
  - install generator that does yarn add and adds lines to stimulus controllers file
83
83
  - find a way to do collection updates, a component that lists many items
84
- - move the component wrapper div out of component (to avoid unsubscribe/subscribe on all updates)
85
84
  - could we do something for components that rely on multiple objects?
86
85
  - allow the listen to method to accept a list of attributes so we only get updates to relevant things
87
86
 
@@ -9,6 +9,11 @@ module ActionView
9
9
  LiveUpdater.subscribe(name.to_s.classify, self)
10
10
  end
11
11
  end
12
+
13
+ def live
14
+ # <div data-controller="live" data-live-component="UserCardComponent" data-live-id="<%= id %>">
15
+ content_tag(:div, nil, data: {controller: :live, live_component: self.class.name, live_id: id}) { yield }
16
+ end
12
17
  end
13
18
  end
14
19
  end
@@ -1,7 +1,7 @@
1
1
  module Actionview
2
2
  module Component
3
3
  module Live
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Træls Ravn