Skip to content

Commit 872fb5c

Browse files
committed
Add Callback{,Option}.voidExplicit
1 parent 023fda6 commit 872fb5c

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

core/src/main/scala/japgolly/scalajs/react/CallbackOption.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,14 @@ final class CallbackOption[A](private val cbfn: () => Option[A]) extends AnyVal
188188
def void: CallbackOption[Unit] =
189189
map(_ => ())
190190

191+
/**
192+
* Discard the value produced by this callback.
193+
*
194+
* This method allows you to be explicit about the type you're discarding (which may change in future).
195+
*/
196+
@inline def voidExplicit[B](implicit ev: A =:= B): Callback =
197+
void
198+
191199
def orElse(tryNext: CallbackOption[A]): CallbackOption[A] =
192200
CallbackOption(get flatMap {
193201
case a@ Some(_) => CallbackTo pure a

doc/CHANGELOG-0.10.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040

4141
* Add `CallbackOption.{pass,fail}`.
4242

43+
* Add `Callback{,Option}.voidExplicit`.
44+
4345
* Add `React.Children.toArray`.
4446

4547
* Upgrade React to 0.14.1. Adds new attributes:

0 commit comments

Comments
 (0)