final class CallbackOption[A] extends AnyVal
Callback that can short-circuit along the way when conditions you specify, aren't met.
Especially useful for event handlers such as key handlers, drag-and-drop handlers, etc, where you check a condition, perform an effect, check another condition, perform another effect, etc.
This is meant to be lightweight, and be immediately useful without the typical pain of imports, implicit conversions and extension methods then normally accompany monad transforms in Scala.
For a more generic (i.e. beyond Option) or comprehensive monad transformer use Scalaz or similar.
- Alphabetic
- By Inheritance
- CallbackOption
- AnyVal
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new CallbackOption(cbfn: () ⇒ Option[A])
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- Any
-
final
def
##(): Int
- Definition Classes
- Any
- def &&[B](b: CallbackOption[B]): CallbackOption[Unit]
-
def
*>[B](next: CallbackOption[B]): CallbackOption[B]
Alias for
>>.Alias for
>>.Where
>>is often associated with Monads,*>is often associated with Applicatives.- Annotations
- @inline()
-
def
<*[B](next: CallbackOption[B]): CallbackOption[A]
Sequence actions, discarding the value of the second argument.
-
def
<<[B](prev: CallbackOption[B]): CallbackOption[A]
Sequence a callback to run before this, discarding any value produced by it.
-
def
<<?[B](prev: Option[CallbackOption[B]]): CallbackOption[A]
Convenient version of
<<that accepts an Option -
final
def
==(arg0: Any): Boolean
- Definition Classes
- Any
-
def
>>[B](next: CallbackOption[B]): CallbackOption[B]
Sequence a callback to run after this, discarding any value produced by this.
-
def
>>=[B](f: (A) ⇒ CallbackOption[B]): CallbackOption[B]
Alias for
flatMap.Alias for
flatMap.- Annotations
- @inline()
- def asCallback: CallbackTo[Option[A]]
-
def
asEventDefault(e: react.ReactEvent): CallbackOption[A]
Wraps this so that:
Wraps this so that:
1) It only executes if
e.defaultPreventedisfalse. 2) It setse.preventDefaulton successful completion. -
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
- def filter(condition: (A) ⇒ Boolean): CallbackOption[A]
- def filterNot(condition: (A) ⇒ Boolean): CallbackOption[A]
- def flatMap[B](f: (A) ⇒ CallbackOption[B]): CallbackOption[B]
- def flatMapCB[B](f: (A) ⇒ CallbackTo[B]): CallbackOption[B]
- def flatMapOption[B](f: (A) ⇒ Option[B]): CallbackOption[B]
-
def
getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
- def getOrElse[AA >: A](default: ⇒ AA): CallbackTo[AA]
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def map[B](f: (A) ⇒ B)(implicit ev: MapGuard[B]): CallbackOption[Out]
- def orElse[AA >: A](tryNext: CallbackOption[AA]): CallbackOption[AA]
- def toCallback(implicit ev: <:<[A, Unit]): Callback
-
def
toString(): String
- Definition Classes
- Any
- def unary_!(implicit ev: <:<[A, Unit]): CallbackOption[Unit]
-
def
underlyingRepr: () ⇒ Option[A]
The underlying representation of this value-class
The underlying representation of this value-class
- Annotations
- @inline()
-
def
unless(cond: ⇒ Boolean): CallbackOption[A]
Conditional execution of this callback.
Conditional execution of this callback. Reverse of when().
- cond
The condition required to be
falsefor this callback to execute.- returns
Someresult of the callback executed, elseNone.
-
def
void: CallbackOption[Unit]
Discard the value produced by this callback.
-
def
voidExplicit[B](implicit ev: <:<[A, B]): CallbackOption[Unit]
Discard the value produced by this callback.
Discard the value produced by this callback.
This method allows you to be explicit about the type you're discarding (which may change in future).
- Annotations
- @inline()
-
def
when(cond: ⇒ Boolean): CallbackOption[A]
Conditional execution of this callback.
Conditional execution of this callback.
- cond
The condition required to be
truefor this callback to execute.
- def widen[B >: A]: CallbackOption[B]
- def withFilter(condition: (A) ⇒ Boolean): CallbackOption[A]
- def zip[B](cb: CallbackOption[B]): CallbackOption[(A, B)]
-
def
|[AA >: A](tryNext: CallbackOption[AA]): CallbackOption[AA]
Alias for
orElse.Alias for
orElse.- Annotations
- @inline()
-
def
|>[B](f: (A) ⇒ B)(implicit ev: MapGuard[B]): CallbackOption[Out]
Alias for
map.Alias for
map.- Annotations
- @inline()
- def ||[B](b: CallbackOption[B]): CallbackOption[Unit]