turbo-rails 0.8.3 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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>broadcast_render_later</tt> or
49
- # <tt>broadcast_render_later_to</tt> to render a turbo stream template with multiple actions.
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
@@ -2,4 +2,4 @@ say "Import Turbo"
2
2
  append_to_file "app/javascript/application.js", %(import "@hotwired/turbo-rails"\n)
3
3
 
4
4
  say "Pin Turbo"
5
- append_to_file "config/importmap.rb", %(pin "@hotwired/turbo-rails", to: "turbo.js", preload: true\n)
5
+ append_to_file "config/importmap.rb", %(pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true\n)
data/lib/turbo/engine.rb CHANGED
@@ -26,7 +26,7 @@ module Turbo
26
26
  # config.after_initialize do
27
27
  # config.assets.precompile -= Turbo::Engine::PRECOMPILE_ASSETS
28
28
  # end
29
- PRECOMPILE_ASSETS = %w( turbo.js turbo.min.js )
29
+ PRECOMPILE_ASSETS = %w( turbo.js turbo.min.js turbo.min.js.map )
30
30
 
31
31
  initializer "turbo.assets" do
32
32
  if Rails.application.config.respond_to?(:assets)
data/lib/turbo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Turbo
2
- VERSION = "0.8.3"
2
+ VERSION = "1.0.1"
3
3
  end
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.8.3
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Stephenson
@@ -10,10 +10,24 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-11-05 00:00:00.000000000 Z
13
+ date: 2022-01-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: rails
16
+ name: actionpack
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: 6.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: 6.0.0
29
+ - !ruby/object:Gem::Dependency
30
+ name: railties
17
31
  requirement: !ruby/object:Gem::Requirement
18
32
  requirements:
19
33
  - - ">="
@@ -37,6 +51,7 @@ files:
37
51
  - Rakefile
38
52
  - app/assets/javascripts/turbo.js
39
53
  - app/assets/javascripts/turbo.min.js
54
+ - app/assets/javascripts/turbo.min.js.map
40
55
  - app/channels/turbo/streams/broadcasts.rb
41
56
  - app/channels/turbo/streams/stream_name.rb
42
57
  - app/channels/turbo/streams_channel.rb
@@ -84,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
99
  - !ruby/object:Gem::Version
85
100
  version: '0'
86
101
  requirements: []
87
- rubygems_version: 3.2.22
102
+ rubygems_version: 3.2.32
88
103
  signing_key:
89
104
  specification_version: 4
90
105
  summary: The speed of a single-page web application without having to write any JavaScript.