live_cable 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 +4 -4
- data/README.md +25 -7
- data/app/assets/javascript/controllers/live_controller.js +1 -1
- data/app/assets/javascript/live_cable.js +3 -3
- data/app/assets/javascript/live_cable_blessing.js +1 -1
- data/app/assets/javascript/observer.js +1 -1
- data/app/assets/javascript/subscriptions.js +1 -1
- data/config/importmap.rb +6 -6
- data/lib/live_cable/engine.rb +4 -2
- data/lib/live_cable/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: e0376ac919c3ed29e3c63181364e512f51aa39aeeb84f1b8a0584b42e1c89985
|
|
4
|
+
data.tar.gz: 8bb42eb86866bddf18fb83e0a16770c4ddb48c3ec22524b680e272d155e22431
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4f95c867c6f65a85ceca7fad4c23cc572bc1cfb6c90e008ebb24403dbc7624cd9977ae711bc133484612b0e3ac16440f3d18bf365c656c8d537f009387dfd0fe
|
|
7
|
+
data.tar.gz: 01d716fd63f39335bbaaed9aa8b0643f5b9a1493b9f1ca449635b4aa7f3cecc6d67992f31503412cbba6fd53860778918627430365af614b8598beb0666306b4
|
data/README.md
CHANGED
|
@@ -48,14 +48,32 @@ end
|
|
|
48
48
|
|
|
49
49
|
## JavaScript Setup
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
LiveCable works with both **importmap-rails** (default for Rails 7+) and **JavaScript bundlers** (esbuild, Vite, webpack, Rollup via jsbundling-rails or vite_ruby).
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
### Using importmap-rails (default)
|
|
54
|
+
|
|
55
|
+
The gem automatically pins all necessary modules when you install it. No additional setup is needed.
|
|
56
|
+
|
|
57
|
+
### Using a JavaScript bundler (yarn/npm)
|
|
58
|
+
|
|
59
|
+
Install the npm package:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
yarn add @isometriks/live_cable
|
|
63
|
+
# or
|
|
64
|
+
npm install @isometriks/live_cable
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
This will also install the required peer dependencies (`@rails/actioncable`, `@hotwired/stimulus`, and `morphdom`).
|
|
68
|
+
|
|
69
|
+
### Register the LiveController
|
|
70
|
+
|
|
71
|
+
Register the `LiveController` in your Stimulus application (`app/javascript/controllers/application.js`). The imports are the same regardless of whether you use importmap or a bundler:
|
|
54
72
|
|
|
55
73
|
```javascript
|
|
56
74
|
import { Application } from "@hotwired/stimulus"
|
|
57
|
-
import LiveController from "
|
|
58
|
-
import "live_cable" // Automatically starts DOM observer
|
|
75
|
+
import LiveController from "@isometriks/live_cable/controller"
|
|
76
|
+
import "@isometriks/live_cable" // Automatically starts DOM observer
|
|
59
77
|
|
|
60
78
|
const application = Application.start()
|
|
61
79
|
application.register("live", LiveController)
|
|
@@ -69,9 +87,9 @@ If you want to call LiveCable actions from your own Stimulus controllers, add th
|
|
|
69
87
|
|
|
70
88
|
```javascript
|
|
71
89
|
import { Application, Controller } from "@hotwired/stimulus"
|
|
72
|
-
import LiveController from "
|
|
73
|
-
import LiveCableBlessing from "
|
|
74
|
-
import "live_cable" // Automatically starts DOM observer
|
|
90
|
+
import LiveController from "@isometriks/live_cable/controller"
|
|
91
|
+
import LiveCableBlessing from "@isometriks/live_cable/blessing"
|
|
92
|
+
import "@isometriks/live_cable" // Automatically starts DOM observer
|
|
75
93
|
|
|
76
94
|
// Enable the blessing for all controllers
|
|
77
95
|
Controller.blessings = [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import LiveObserver from '
|
|
2
|
-
import SubscriptionManager from '
|
|
3
|
-
import DOM from '
|
|
1
|
+
import LiveObserver from '@isometriks/live_cable/observer'
|
|
2
|
+
import SubscriptionManager from '@isometriks/live_cable/subscriptions'
|
|
3
|
+
import DOM from '@isometriks/live_cable/dom'
|
|
4
4
|
|
|
5
5
|
const observer = new LiveObserver()
|
|
6
6
|
observer.start()
|
data/config/importmap.rb
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
pin '@rails/actioncable', to: 'actioncable.esm.js'
|
|
4
4
|
pin 'morphdom', to: 'https://ga.jspm.io/npm:morphdom@2.7.8/dist/morphdom-esm.js'
|
|
5
5
|
|
|
6
|
-
pin '
|
|
7
|
-
pin '
|
|
8
|
-
pin '
|
|
9
|
-
pin '
|
|
10
|
-
pin '
|
|
11
|
-
pin 'live_cable', to: 'live_cable.js'
|
|
6
|
+
pin '@isometriks/live_cable/controller', to: 'controllers/live_controller.js'
|
|
7
|
+
pin '@isometriks/live_cable/blessing', to: 'live_cable_blessing.js'
|
|
8
|
+
pin '@isometriks/live_cable/subscriptions', to: 'subscriptions.js'
|
|
9
|
+
pin '@isometriks/live_cable/observer', to: 'observer.js'
|
|
10
|
+
pin '@isometriks/live_cable/dom', to: 'dom.js'
|
|
11
|
+
pin '@isometriks/live_cable', to: 'live_cable.js'
|
data/lib/live_cable/engine.rb
CHANGED
|
@@ -12,8 +12,10 @@ module LiveCable
|
|
|
12
12
|
warn("[LiveCable Warning] #{live_component_dir} does not exist for components.")
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
# Add LiveCable to importmap
|
|
16
|
-
app.config.
|
|
15
|
+
# Add LiveCable to importmap (skip when using jsbundling/npm)
|
|
16
|
+
if app.config.respond_to?(:importmap)
|
|
17
|
+
app.config.importmap.paths << root.join('config/importmap.rb')
|
|
18
|
+
end
|
|
17
19
|
end
|
|
18
20
|
|
|
19
21
|
initializer 'live_cable.assets_precompile' do |app|
|
data/lib/live_cable/version.rb
CHANGED