turbo-rails 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/turbo.js +66 -17
- data/app/assets/javascripts/turbo.min.js +3 -3
- data/app/assets/javascripts/turbo.min.js.map +1 -1
- data/app/channels/turbo/streams_channel.rb +1 -1
- data/app/models/concerns/turbo/broadcastable.rb +24 -6
- data/lib/turbo/version.rb +1 -1
- metadata +2 -2
@@ -9,7 +9,7 @@
|
|
9
9
|
# helper modules like <tt>Turbo::Streams::StreamName</tt>:
|
10
10
|
#
|
11
11
|
# class CustomChannel < ActionCable::Channel::Base
|
12
|
-
# extend Turbo::
|
12
|
+
# extend Turbo::Streams::Broadcasts, Turbo::Streams::StreamName
|
13
13
|
# include Turbo::Streams::StreamName::ClassMethods
|
14
14
|
#
|
15
15
|
# def subscribed
|
@@ -45,8 +45,9 @@
|
|
45
45
|
# within a real-time path, like a controller or model, since all those updates require a rendering step, which can slow down
|
46
46
|
# execution. You don't need to do this for remove, since only the dom id for the model is used.
|
47
47
|
#
|
48
|
-
# In addition to the four basic actions, you can also use <tt>
|
49
|
-
# <tt>
|
48
|
+
# In addition to the four basic actions, you can also use <tt>broadcast_render</tt>,
|
49
|
+
# <tt>broadcast_render_to</tt> <tt>broadcast_render_later</tt>, and <tt>broadcast_render_later_to</tt>
|
50
|
+
# to render a turbo stream template with multiple actions.
|
50
51
|
module Turbo::Broadcastable
|
51
52
|
extend ActiveSupport::Concern
|
52
53
|
|
@@ -275,9 +276,7 @@ module Turbo::Broadcastable
|
|
275
276
|
broadcast_action_later_to self, action: action, target: target, **rendering
|
276
277
|
end
|
277
278
|
|
278
|
-
|
279
|
-
# Render a turbo stream template asynchronously with this broadcastable model passed as the local variable using a
|
280
|
-
# <tt>Turbo::Streams::BroadcastJob</tt>. Example:
|
279
|
+
# Render a turbo stream template with this broadcastable model passed as the local variable. Example:
|
281
280
|
#
|
282
281
|
# # Template: entries/_entry.turbo_stream.erb
|
283
282
|
# <%= turbo_stream.remove entry %>
|
@@ -289,7 +288,26 @@ module Turbo::Broadcastable
|
|
289
288
|
# <turbo-stream action="remove" target="entry_5"></turbo-stream>
|
290
289
|
# <turbo-stream action="append" target="entries"><template><div id="entry_5">My Entry</div></template></turbo-stream>
|
291
290
|
#
|
292
|
-
# ...to the stream named "entry:5"
|
291
|
+
# ...to the stream named "entry:5".
|
292
|
+
#
|
293
|
+
# Note that rendering inline via this method will cause template rendering to happen synchronously. That is usually not
|
294
|
+
# desireable for model callbacks, certainly not if those callbacks are inside of a transaction. Most of the time you should
|
295
|
+
# be using `broadcast_render_later`, unless you specifically know why synchronous rendering is needed.
|
296
|
+
def broadcast_render(**rendering)
|
297
|
+
broadcast_render_to self, **rendering
|
298
|
+
end
|
299
|
+
|
300
|
+
# Same as <tt>broadcast_render</tt> but run with the added option of naming the stream using the passed
|
301
|
+
# <tt>streamables</tt>.
|
302
|
+
#
|
303
|
+
# Note that rendering inline via this method will cause template rendering to happen synchronously. That is usually not
|
304
|
+
# desireable for model callbacks, certainly not if those callbacks are inside of a transaction. Most of the time you should
|
305
|
+
# be using `broadcast_render_later_to`, unless you specifically know why synchronous rendering is needed.
|
306
|
+
def broadcast_render_to(*streamables, **rendering)
|
307
|
+
Turbo::StreamsChannel.broadcast_render_to(*streamables, **broadcast_rendering_with_defaults(rendering))
|
308
|
+
end
|
309
|
+
|
310
|
+
# Same as <tt>broadcast_action_to</tt> but run asynchronously via a <tt>Turbo::Streams::BroadcastJob</tt>.
|
293
311
|
def broadcast_render_later(**rendering)
|
294
312
|
broadcast_render_later_to self, **rendering
|
295
313
|
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: 1.0.
|
4
|
+
version: 1.0.1
|
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:
|
13
|
+
date: 2022-01-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: actionpack
|