turbo-rails 2.0.0.pre.beta.1 → 2.0.0.pre.beta.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,4 +8,6 @@ export { cable }
8
8
 
9
9
  import { encodeMethodIntoRequestBody } from "./fetch_requests"
10
10
 
11
+ window.Turbo = Turbo
12
+
11
13
  addEventListener("turbo:before-fetch-request", encodeMethodIntoRequestBody)
@@ -2,7 +2,7 @@
2
2
  # turbo stream templates.
3
3
  class Turbo::Streams::BroadcastJob < ActiveJob::Base
4
4
  discard_on ActiveJob::DeserializationError
5
-
5
+
6
6
  def perform(stream, **rendering)
7
7
  Turbo::StreamsChannel.broadcast_render_to stream, **rendering
8
8
  end
@@ -142,9 +142,11 @@ module Turbo::Broadcastable
142
142
  end
143
143
 
144
144
  # Same as <tt>#broadcasts_refreshes_to</tt>, but the designated stream for page refreshes is automatically set to
145
- # the current model.
146
- def broadcasts_refreshes
147
- after_commit -> { broadcast_refresh_later }
145
+ # the current model, for creates - to the model plural name, which can be overriden by passing <tt>stream</tt>.
146
+ def broadcasts_refreshes(stream = model_name.plural)
147
+ after_create_commit -> { broadcast_refresh_later_to(stream) }
148
+ after_update_commit -> { broadcast_refresh_later }
149
+ after_destroy_commit -> { broadcast_refresh }
148
150
  end
149
151
 
150
152
  # All default targets will use the return of this method. Overwrite if you want something else than <tt>model_name.plural</tt>.
data/lib/turbo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Turbo
2
- VERSION = "2.0.0-beta.1"
2
+ VERSION = "2.0.0-beta.2"
3
3
  end
data/lib/turbo-rails.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "turbo/engine"
2
+ require "active_support/core_ext/module/attribute_accessors_per_thread"
2
3
 
3
4
  module Turbo
4
5
  extend ActiveSupport::Autoload
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: 2.0.0.pre.beta.1
4
+ version: 2.0.0.pre.beta.2
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: 2023-11-23 00:00:00.000000000 Z
13
+ date: 2023-12-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activejob