actionview-component-live 0.1.1 → 0.1.2
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e3e1d0cee952a9a568c584e3107e4768de18e527b2edf4c4ef0fa209b037214
|
4
|
+
data.tar.gz: d0072b8cb8ceab9868fb7f41eaf6c89b89397d627a96bdd8bb3b8f2c6f3b03b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
33
|
-
|
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
|
-
|
35
|
+
<%= live do %>
|
36
36
|
<b><%= count %> products in basket</b>
|
37
|
-
|
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
|