Class/Object

japgolly.scalajs.react

CallbackTo

Related Docs: object CallbackTo | package react

Permalink

final class CallbackTo[A] extends AnyVal

A function to be executed later, usually by scalajs-react in response to some kind of event.

The purpose of this class is to lift effects into the type system, and use the compiler to ensure safety around callbacks (without depending on an external library like Scalaz).

() => Unit is replaced by Callback. Similarly, ReactEvent => Unit is replaced by ReactEvent => Callback.

A

The type of result produced when the callback is invoked.

Since

0.10.0

Linear Supertypes
AnyVal, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. CallbackTo
  2. AnyVal
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. def !(implicit ev: <:<[CallbackTo[A], CallbackTo[Boolean]]): CallbackTo[Boolean]

    Permalink

    Negates the callback result (so long as it's boolean).

  2. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    Any
  3. final def ##(): Int

    Permalink
    Definition Classes
    Any
  4. def &&(b: CallbackTo[Boolean])(implicit ev: <:<[CallbackTo[A], CallbackTo[Boolean]]): CallbackTo[Boolean]

    Permalink

    Creates a new callback that returns true when both this and the given callback return true.

  5. def *>[B](runNext: CallbackTo[B]): CallbackTo[B]

    Permalink

    Alias for >>.

    Alias for >>.

    Where >> is often associated with Monads, *> is often associated with Applicatives.

    Annotations
    @inline()
  6. def <*[B](next: CallbackTo[B]): CallbackTo[A]

    Permalink

    Sequence actions, discarding the value of the second argument.

  7. def <<[B](runBefore: CallbackTo[B]): CallbackTo[A]

    Permalink

    Sequence a callback to run before this, discarding any value produced by it.

    Sequence a callback to run before this, discarding any value produced by it.

    Annotations
    @inline()
  8. def <|(t: (A) ⇒ Any): CallbackTo[A]

    Permalink

    Alias for tap.

    Alias for tap.

    Annotations
    @inline()
  9. def =<<:[B](g: (A) ⇒ CallbackTo[B]): CallbackTo[B]

    Permalink

    Same as flatMap and >>=, but allows arguments to appear in reverse order.

    Same as flatMap and >>=, but allows arguments to appear in reverse order.

    i.e. f >>= g is the same as g =<<: f

    Annotations
    @inline()
  10. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    Any
  11. def >>[B](runNext: CallbackTo[B]): CallbackTo[B]

    Permalink

    Sequence a callback to run after this, discarding any value produced by this.

  12. def >>=[B](g: (A) ⇒ CallbackTo[B]): CallbackTo[B]

    Permalink

    Alias for flatMap.

    Alias for flatMap.

    Annotations
    @inline()
  13. def asCBO[B](implicit ev: <:<[CallbackTo[A], CallbackTo[Option[B]]]): CallbackOption[B]

    Permalink
  14. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  15. def async: CallbackTo[Future[A]]

    Permalink

    Run asynchronously.

  16. def attempt: CallbackTo[Either[Throwable, A]]

    Permalink

    Wraps this callback in a try-catch and returns either the result or the exception if one occurs.

  17. def attemptTry: CallbackTo[Try[A]]

    Permalink

    Wraps this callback in a scala Try with catches what it considers non-fatal errors.

    Wraps this callback in a scala Try with catches what it considers non-fatal errors.

    Use attempt to catch everything.

  18. def delay(startIn: FiniteDuration): CallbackTo[Future[A]]

    Permalink

    Run asynchronously after a delay of a given duration.

  19. def delayMs(startInMilliseconds: Double): CallbackTo[Future[A]]

    Permalink

    Run asynchronously after a startInMilliseconds ms delay.

  20. def distFn[B, C](implicit ev: <:<[CallbackTo[A], CallbackTo[(B) ⇒ C]]): (B) ⇒ CallbackTo[C]

    Permalink
  21. def finallyRun[B](runFinally: CallbackTo[B]): CallbackTo[A]

    Permalink

    Wraps this callback in a try-finally block and runs the given callback in the finally clause, after the current callback completes, be it in error or success.

  22. def flatMap[B](g: (A) ⇒ CallbackTo[B]): CallbackTo[B]

    Permalink
  23. def flatMap2[X, Y, Z](f: (X, Y) ⇒ CallbackTo[Z])(implicit ev: <:<[A, (X, Y)]): CallbackTo[Z]

    Permalink
  24. def flatTap[B](t: (A) ⇒ CallbackTo[B]): CallbackTo[A]

    Permalink
  25. def flatten[B](implicit ev: (A) ⇒ CallbackTo[B]): CallbackTo[B]

    Permalink
  26. def getClass(): Class[_ <: AnyVal]

    Permalink
    Definition Classes
    AnyVal → Any
  27. def isEmpty_?: Boolean

    Permalink
  28. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  29. def logAround(message: Any, optionalParams: Any*): CallbackTo[A]

    Permalink

    Log to the console before this callback starts, and after it completes.

    Log to the console before this callback starts, and after it completes.

    Does not change the result.

  30. def logDuration: CallbackTo[A]

    Permalink

    Log the duration of this callback's execution.

  31. def logDuration(name: String): CallbackTo[A]

    Permalink

    Log the duration of this callback's execution.

    Log the duration of this callback's execution.

    name

    Prefix to appear the log output.

  32. def logDuration(fmt: (FiniteDuration) ⇒ String): CallbackTo[A]

    Permalink

    Log the duration of this callback's execution.

  33. def logResult: CallbackTo[A]

    Permalink

    Logs the result of this callback as it completes.

  34. def logResult(name: String): CallbackTo[A]

    Permalink

    Logs the result of this callback as it completes.

    Logs the result of this callback as it completes.

    name

    Prefix to appear the log output.

  35. def logResult(msg: (A) ⇒ String): CallbackTo[A]

    Permalink

    Logs the result of this callback as it completes.

  36. def map[B](g: (A) ⇒ B)(implicit ev: MapGuard[B]): CallbackTo[Out]

    Permalink
  37. def precedeWith(runFirst: ⇒ Unit): CallbackTo[A]

    Permalink

    Convenience-method to run additional code before this callback.

  38. def ret[B](b: B): CallbackTo[B]

    Permalink

    Discard the callback's return value, return a given value instead.

    Discard the callback's return value, return a given value instead.

    ret, short for return.

  39. def runNow(): A

    Permalink

    Executes this callback, on the current thread, right now, blocking until complete.

    Executes this callback, on the current thread, right now, blocking until complete.

    In most cases, this type is passed to scalajs-react such that you don't need to call this method yourself.

    Exceptions will not be caught. Use attempt to catch thrown exceptions.

    Annotations
    @inline()
  40. def tap(t: (A) ⇒ Any): CallbackTo[A]

    Permalink

    When the callback result becomes available, perform a given side-effect with it.

  41. def thenRun[B](runNext: ⇒ B)(implicit ev: MapGuard[B]): CallbackTo[Out]

    Permalink

    Convenience-method to run additional code after this callback.

  42. def toCBO: CallbackOption[A]

    Permalink
  43. def toFuture(implicit ec: ExecutionContext): Future[A]

    Permalink

    Schedules an instance of this callback to run asynchronously.

  44. def toJsCallback: UndefOr[Function0[A]]

    Permalink
  45. def toJsFn: Function0[A]

    Permalink
  46. def toJsFn1: Function1[Any, A]

    Permalink
  47. def toScalaFn: () ⇒ A

    Permalink
    Annotations
    @inline()
  48. def toString(): String

    Permalink
    Definition Classes
    Any
  49. def unless(cond: ⇒ Boolean): CallbackTo[Option[A]]

    Permalink

    Conditional execution of this callback.

    Conditional execution of this callback. Reverse of when().

    cond

    The condition required to be false for this callback to execute.

    returns

    Some result of the callback executed, else None.

  50. def unless_(cond: ⇒ Boolean): Callback

    Permalink

    Conditional execution of this callback.

    Conditional execution of this callback. Discards the result. Reverse of when_().

    cond

    The condition required to be false for the callback to execute.

  51. def void: Callback

    Permalink

    Discard the value produced by this callback.

  52. def voidExplicit[B](implicit ev: <:<[A, B]): Callback

    Permalink

    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()
  53. def when(cond: ⇒ Boolean): CallbackTo[Option[A]]

    Permalink

    Conditional execution of this callback.

    Conditional execution of this callback.

    cond

    The condition required to be true for this callback to execute.

    returns

    Some result of the callback executed, else None.

  54. def when_(cond: ⇒ Boolean): Callback

    Permalink

    Conditional execution of this callback.

    Conditional execution of this callback. Discards the result.

    cond

    The condition required to be true for this callback to execute.

  55. def widen[B >: A]: CallbackTo[B]

    Permalink
  56. def withDuration[B](f: (A, FiniteDuration) ⇒ CallbackTo[B]): CallbackTo[B]

    Permalink

    Record the duration of this callback's execution.

  57. def zip[B](cb: CallbackTo[B]): CallbackTo[(A, B)]

    Permalink
  58. def |>[B](g: (A) ⇒ B)(implicit ev: MapGuard[B]): CallbackTo[Out]

    Permalink

    Alias for map.

    Alias for map.

    Annotations
    @inline()
  59. def ||(b: CallbackTo[Boolean])(implicit ev: <:<[CallbackTo[A], CallbackTo[Boolean]]): CallbackTo[Boolean]

    Permalink

    Creates a new callback that returns true when either this or the given callback return true.

Deprecated Value Members

  1. def conditionally(cond: ⇒ Boolean): CallbackTo[Option[A]]

    Permalink
    Annotations
    @deprecated
    Deprecated

    (Since version 0.11.0) Use when() or unless().

Inherited from AnyVal

Inherited from Any

Ungrouped