turbo-rails 0.7.6 → 0.7.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/app/channels/turbo/streams/broadcasts.rb +30 -32
- data/lib/turbo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f96104fa6d1282a5f3845a119e748b04a819078840d3750604ebebeac081871
|
4
|
+
data.tar.gz: 0fdbf552964ff5ada90d746a32ec5575181c010471f4dcd921c2b443bfc732af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 662af2c0c6187537aafc70747ed3f66215bc65bde320475d12d10aeb30d2aca17ed1a3fa1403033a73f51323969782e3e482d5c145a3d0382921045eff22f2cb
|
7
|
+
data.tar.gz: 23a86030ac88022ba35c3b9369e1cf73bc2803e3c6106abb22ac9b179bb170b78e732fbab873eb56698f7a4c262298f2ab962f89359bd2369ac71820205df513
|
data/README.md
CHANGED
@@ -15,6 +15,15 @@ During rendering, Turbo replaces the current `<body>` element outright and merge
|
|
15
15
|
|
16
16
|
Whereas Turbolinks previously just dealt with links, Turbo can now also process form submissions and responses. This means the entire flow in the web application is wrapped into Turbo, making all the parts fast. No more need for `data-remote=true`.
|
17
17
|
|
18
|
+
Turbo Drive can be disabled on a per-element basis by annotating the element or any of its ancestors with `data-turbo="false"`. If you want Turbo Drive to be disabled by default, then you can adjust your import like this:
|
19
|
+
|
20
|
+
```js
|
21
|
+
import { Turbo } from "@hotwired/turbo-rails"
|
22
|
+
Turbo.session.drive = false
|
23
|
+
```
|
24
|
+
|
25
|
+
Then you can use `data-turbo="true"` to enable Drive on a per-element basis.
|
26
|
+
|
18
27
|
|
19
28
|
## Turbo Frames
|
20
29
|
|
@@ -37,6 +46,7 @@ The JavaScript for Turbo can either be run through the asset pipeline, which is
|
|
37
46
|
1. Add the `turbo-rails` gem to your Gemfile: `gem 'turbo-rails'`
|
38
47
|
2. Run `./bin/bundle install`
|
39
48
|
3. Run `./bin/rails turbo:install`
|
49
|
+
4. Run `./bin/rails turbo:install:redis` to change the development Action Cable adapter from Async (the default one) to Redis. The Async adapter does not support Turbo Stream broadcasting.
|
40
50
|
|
41
51
|
Running `turbo:install` will install through NPM if Webpacker is installed in the application. Otherwise the asset pipeline version is used. To use the asset pipeline version, you must have `importmap-rails` installed first and listed higher in the Gemfile.
|
42
52
|
|
@@ -48,6 +58,7 @@ The `Turbo` instance is automatically assigned to `window.Turbo` upon import:
|
|
48
58
|
import "@hotwired/turbo-rails"
|
49
59
|
```
|
50
60
|
|
61
|
+
|
51
62
|
## Usage
|
52
63
|
|
53
64
|
You can watch [the video introduction to Hotwire](https://hotwired.dev/#screencast), which focuses extensively on demonstration Turbo in a Rails demo. Then you should familiarize yourself with [Turbo handbook](https://turbo.hotwired.dev/handbook/introduction) to understand Drive, Frames, and Streams in-depth. Finally, dive into the code documentation by starting with [`Turbo::FramesHelper`](https://github.com/hotwired/turbo-rails/blob/main/app/helpers/turbo/frames_helper.rb), [`Turbo::StreamsHelper`](https://github.com/hotwired/turbo-rails/blob/main/app/helpers/turbo/streams_helper.rb), [`Turbo::Streams::TagBuilder`](https://github.com/hotwired/turbo-rails/blob/main/app/models/turbo/streams/tag_builder.rb), and [`Turbo::Broadcastable`](https://github.com/hotwired/turbo-rails/blob/main/app/models/concerns/turbo/broadcastable.rb).
|
@@ -5,71 +5,69 @@
|
|
5
5
|
module Turbo::Streams::Broadcasts
|
6
6
|
include Turbo::Streams::ActionHelper
|
7
7
|
|
8
|
-
def broadcast_remove_to(*streamables,
|
9
|
-
broadcast_action_to *streamables, action: :remove,
|
8
|
+
def broadcast_remove_to(*streamables, **opts)
|
9
|
+
broadcast_action_to *streamables, action: :remove, **opts
|
10
10
|
end
|
11
11
|
|
12
|
-
def broadcast_replace_to(*streamables,
|
13
|
-
broadcast_action_to *streamables, action: :replace,
|
12
|
+
def broadcast_replace_to(*streamables, **opts)
|
13
|
+
broadcast_action_to *streamables, action: :replace, **opts
|
14
14
|
end
|
15
15
|
|
16
|
-
def broadcast_update_to(*streamables,
|
17
|
-
broadcast_action_to *streamables, action: :update,
|
16
|
+
def broadcast_update_to(*streamables, **opts)
|
17
|
+
broadcast_action_to *streamables, action: :update, **opts
|
18
18
|
end
|
19
19
|
|
20
|
-
def broadcast_before_to(*streamables,
|
21
|
-
broadcast_action_to *streamables, action: :before,
|
20
|
+
def broadcast_before_to(*streamables, **opts)
|
21
|
+
broadcast_action_to *streamables, action: :before, **opts
|
22
22
|
end
|
23
23
|
|
24
|
-
def broadcast_after_to(*streamables,
|
25
|
-
broadcast_action_to *streamables, action: :after,
|
24
|
+
def broadcast_after_to(*streamables, **opts)
|
25
|
+
broadcast_action_to *streamables, action: :after, **opts
|
26
26
|
end
|
27
27
|
|
28
|
-
def broadcast_append_to(*streamables,
|
29
|
-
broadcast_action_to *streamables, action: :append,
|
28
|
+
def broadcast_append_to(*streamables, **opts)
|
29
|
+
broadcast_action_to *streamables, action: :append, **opts
|
30
30
|
end
|
31
31
|
|
32
|
-
def broadcast_prepend_to(*streamables,
|
33
|
-
broadcast_action_to *streamables, action: :prepend,
|
32
|
+
def broadcast_prepend_to(*streamables, **opts)
|
33
|
+
broadcast_action_to *streamables, action: :prepend, **opts
|
34
34
|
end
|
35
35
|
|
36
|
-
def broadcast_action_to(*streamables, action:, target
|
37
|
-
broadcast_stream_to *streamables, content: turbo_stream_action_tag(action, target: target, template:
|
36
|
+
def broadcast_action_to(*streamables, action:, target: nil, targets: nil, **rendering)
|
37
|
+
broadcast_stream_to *streamables, content: turbo_stream_action_tag(action, target: target, targets: targets, template:
|
38
38
|
rendering.delete(:content) || (rendering.any? ? render_format(:html, **rendering) : nil)
|
39
39
|
)
|
40
40
|
end
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
broadcast_action_later_to *streamables, action: :replace, target: target, **rendering
|
42
|
+
def broadcast_replace_later_to(*streamables, **opts)
|
43
|
+
broadcast_action_later_to *streamables, action: :replace, **opts
|
45
44
|
end
|
46
45
|
|
47
|
-
def broadcast_update_later_to(*streamables,
|
48
|
-
broadcast_action_later_to *streamables, action: :update,
|
46
|
+
def broadcast_update_later_to(*streamables, **opts)
|
47
|
+
broadcast_action_later_to *streamables, action: :update, **opts
|
49
48
|
end
|
50
49
|
|
51
|
-
def broadcast_before_later_to(*streamables,
|
52
|
-
broadcast_action_later_to *streamables, action: :before,
|
50
|
+
def broadcast_before_later_to(*streamables, **opts)
|
51
|
+
broadcast_action_later_to *streamables, action: :before, **opts
|
53
52
|
end
|
54
53
|
|
55
|
-
def broadcast_after_later_to(*streamables,
|
56
|
-
broadcast_action_later_to *streamables, action: :after,
|
54
|
+
def broadcast_after_later_to(*streamables, **opts)
|
55
|
+
broadcast_action_later_to *streamables, action: :after, **opts
|
57
56
|
end
|
58
57
|
|
59
|
-
def broadcast_append_later_to(*streamables,
|
60
|
-
broadcast_action_later_to *streamables, action: :append,
|
58
|
+
def broadcast_append_later_to(*streamables, **opts)
|
59
|
+
broadcast_action_later_to *streamables, action: :append, **opts
|
61
60
|
end
|
62
61
|
|
63
|
-
def broadcast_prepend_later_to(*streamables,
|
64
|
-
broadcast_action_later_to *streamables, action: :prepend,
|
62
|
+
def broadcast_prepend_later_to(*streamables, **opts)
|
63
|
+
broadcast_action_later_to *streamables, action: :prepend, **opts
|
65
64
|
end
|
66
65
|
|
67
|
-
def broadcast_action_later_to(*streamables, action:, target
|
66
|
+
def broadcast_action_later_to(*streamables, action:, target: nil, targets: nil, **rendering)
|
68
67
|
Turbo::Streams::ActionBroadcastJob.perform_later \
|
69
|
-
stream_name_from(streamables), action: action, target: target, **rendering
|
68
|
+
stream_name_from(streamables), action: action, target: target, targets: targets, **rendering
|
70
69
|
end
|
71
70
|
|
72
|
-
|
73
71
|
def broadcast_render_to(*streamables, **rendering)
|
74
72
|
broadcast_stream_to *streamables, content: render_format(:turbo_stream, **rendering)
|
75
73
|
end
|
data/lib/turbo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turbo-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Stephenson
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-08-
|
13
|
+
date: 2021-08-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|