Skip to content

Commit

Permalink
Rename PublicBroadcaster#{broadcast->publish}
Browse files Browse the repository at this point in the history
Workaround for scala/bug#12809
  • Loading branch information
nafg committed Jun 22, 2023
1 parent 00952de commit 158481d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Messages {
private object broadcaster extends PublicBroadcaster[Message]

def post(timeout: Double = 1000)(content: TagMod*): Unit =
broadcaster.broadcast(Message(timeout, content.toTagMod)).runNow()
broadcaster.publish(Message(timeout, content.toTagMod)).runNow()
def postCB(timeout: Double = 1000)(content: TagMod*) = Callback {
post(timeout)(content *)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@ package io.github.nafg.scalajs.react.util
import japgolly.scalajs.react.extra.Broadcaster


/**
* Allows publishing a message from outside the class.
*
* `Broadcaster#broacast` is `protected` so it can only be called from within.
*
* Due to https://github.com/scala/bug/issues/12809, we can't override `broadcast`
* so this trait adds a public alternative called `publish` instead.
*
* @tparam A The type of messages that can be broadcasted.
*/
trait PublicBroadcaster[A] extends Broadcaster[A] {
// overriding to make it public
override def broadcast(a: A) = super.broadcast(a)
def publish(a: A) = broadcast(a)
}

0 comments on commit 158481d

Please sign in to comment.