final class AsyncCallback[A] extends AnyVal

Pure asynchronous callback.

You can think of this as being similar to using Future - you can use it in for-comprehensions the same way - except AsyncCallback is pure and doesn't need an ExecutionContext.

When combining instances, it's good to know which methods are sequential and which are parallel (or at least concurrent).

The following methods are sequential: - >>=() / flatMap() - >>() & <<() - flatTap()

The following methods are effectively parallel: - *>() & <*() - race() - zip() & zipWith() - AsyncCallback.traverse et al

In order to actually run this, or get it into a shape in which in can be run, use one of the following: - toCallback <-- most common - asCallbackToFuture - asCallbackToJsPromise - unsafeToFuture() - unsafeToJsPromise()

A good example is the [Ajax 2 demo](https://japgolly.github.io/scalajs-react/#examples/ajax-2).

A

The type of data asynchronously produced on success.

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

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    Any
  2. final def ##: Int
    Definition Classes
    Any
  3. def *>[B](next: AsyncCallback[B]): AsyncCallback[B]

    Start both this and the given callback at once and when both have completed successfully, discard the value produced by this.

  4. def <*[B](next: AsyncCallback[B]): AsyncCallback[A]

    Start both this and the given callback at once and when both have completed successfully, discard the value produced by the given callback.

  5. def <<[B](runBefore: AsyncCallback[B]): AsyncCallback[A]

    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()
  6. def <<?[B](prev: Option[AsyncCallback[B]]): AsyncCallback[A]

    Convenient version of << that accepts an Option

  7. def <|(t: (A) => Any): AsyncCallback[A]

    Alias for tap.

    Alias for tap.

    Annotations
    @inline()
  8. final def ==(arg0: Any): Boolean
    Definition Classes
    Any
  9. def >>[B](runNext: AsyncCallback[B]): AsyncCallback[B]

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

  10. def >>=[B](g: (A) => AsyncCallback[B]): AsyncCallback[B]

    Alias for flatMap.

    Alias for flatMap.

    Annotations
    @inline()
  11. def asCallbackToFuture: CallbackTo[Future[A]]
  12. def asCallbackToJsPromise: CallbackTo[Promise[A]]
  13. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  14. def attempt: AsyncCallback[Either[Throwable, A]]

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

  15. def attemptTry: AsyncCallback[Try[A]]
  16. val completeWith: ((Try[A]) => Callback) => Callback
  17. def delay(dur: FiniteDuration): AsyncCallback[A]
  18. def delay(dur: Duration): AsyncCallback[A]
  19. def delayMs(milliseconds: Double): AsyncCallback[A]
  20. def distFn[B, C](implicit ev: <:<[AsyncCallback[A], AsyncCallback[(B) => C]]): (B) => AsyncCallback[C]

    Function distribution.

    Function distribution. See AsyncCallback.liftTraverse(f).id for the dual.

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

    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 finallyRunSync[B](runFinally: CallbackTo[B]): AsyncCallback[A]

    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.

    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.

    Annotations
    @inline()
  23. def flatMap[B](f: (A) => AsyncCallback[B]): AsyncCallback[B]
  24. def flatMapSync[B](f: (A) => CallbackTo[B]): AsyncCallback[B]
  25. def flatTap[B](t: (A) => AsyncCallback[B]): AsyncCallback[A]
  26. def flatTapSync[B](t: (A) => CallbackTo[B]): AsyncCallback[A]
  27. def flatten[B](implicit ev: (A) => AsyncCallback[B]): AsyncCallback[B]
  28. def flattenSync[B](implicit ev: (A) => CallbackTo[B]): AsyncCallback[B]
  29. def getClass(): Class[_ <: AnyVal]
    Definition Classes
    AnyVal → Any
  30. def handleError(f: (Throwable) => AsyncCallback[A]): AsyncCallback[A]
  31. def handleErrorSync(f: (Throwable) => CallbackTo[A]): AsyncCallback[A]
  32. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  33. def logAround(message: Any, optionalParams: Any*): AsyncCallback[A]

    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.

  34. def logResult: AsyncCallback[A]

    Logs the result of this callback as it completes.

  35. def logResult(name: String): AsyncCallback[A]

    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.

  36. def logResult(msg: (A) => String): AsyncCallback[A]

    Logs the result of this callback as it completes.

  37. def map[B](f: (A) => B): AsyncCallback[B]
  38. def maybeHandleError(f: PartialFunction[Throwable, AsyncCallback[A]]): AsyncCallback[A]
  39. def maybeHandleErrorSync(f: PartialFunction[Throwable, CallbackTo[A]]): AsyncCallback[A]
  40. def memo(): AsyncCallback[A]

    Return a version of this callback that will only execute once, and reuse the result for all other invocations.

  41. def race[B](that: AsyncCallback[B]): AsyncCallback[Either[A, B]]

    Start both this and the given callback at once use the first result to become available, regardless of whether it's a success or failure.

  42. def ret[B](b: B): AsyncCallback[B]

    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.

  43. def runNow(): Unit
  44. def setInterval(dur: FiniteDuration): CallbackTo[SetIntervalResult]

    Schedule for repeated execution every dur.

    Schedule for repeated execution every dur.

    Annotations
    @inline()
  45. def setInterval(dur: Duration): CallbackTo[SetIntervalResult]

    Schedule for repeated execution every dur.

    Schedule for repeated execution every dur.

    Annotations
    @inline()
  46. def setIntervalMs(milliseconds: Double): CallbackTo[SetIntervalResult]

    Schedule for repeated execution every x milliseconds.

    Schedule for repeated execution every x milliseconds.

    Annotations
    @inline()
  47. def setTimeout(dur: FiniteDuration): CallbackTo[SetTimeoutResult]

    Schedule for execution after dur.

    Schedule for execution after dur.

    Note: it most cases delay() is a better alternative.

    Annotations
    @inline()
  48. def setTimeout(dur: Duration): CallbackTo[SetTimeoutResult]

    Schedule for execution after dur.

    Schedule for execution after dur.

    Note: it most cases delay() is a better alternative.

    Annotations
    @inline()
  49. def setTimeoutMs(milliseconds: Double): CallbackTo[SetTimeoutResult]

    Schedule for execution after x milliseconds.

    Schedule for execution after x milliseconds.

    Note: it most cases delayMs() is a better alternative.

    Annotations
    @inline()
  50. def sync: CallbackTo[Either[AsyncCallback[A], A]]

    Returns a synchronous Callback that when run, returns the result on the Right if this AsyncCallback is actually synchronous, else returns a new AsyncCallback on the Left that waits for the async computation to complete.

  51. def tap(t: (A) => Any): AsyncCallback[A]

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

  52. def toCallback: Callback
  53. def toString(): String
    Definition Classes
    Any
  54. def underlyingRepr: ((Try[A]) => Callback) => Callback
    Annotations
    @inline()
  55. def unless(cond: => Boolean): AsyncCallback[Option[A]]

    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.

  56. def unless_(cond: => Boolean): AsyncCallback[Unit]

    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.

  57. def unsafeRunNowSync(): A

    THIS IS VERY CONVENIENT IN UNIT TESTS BUT DO NOT RUN THIS IN PRODUCTION CODE.

    THIS IS VERY CONVENIENT IN UNIT TESTS BUT DO NOT RUN THIS IN PRODUCTION CODE.

    Executes this now, expecting and returning a synchronous result. If there are any asynchronous computations this will throw an exception.

  58. def unsafeToFuture(): Future[A]
  59. def unsafeToJsPromise(): Promise[A]
  60. def void: AsyncCallback[Unit]

    Discard the value produced by this callback.

  61. def voidExplicit[B](implicit ev: <:<[A, B]): AsyncCallback[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()
  62. def when(cond: => Boolean): AsyncCallback[Option[A]]

    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.

  63. def when_(cond: => Boolean): AsyncCallback[Unit]

    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.

  64. def widen[B >: A]: AsyncCallback[B]
  65. def zip[B](that: AsyncCallback[B]): AsyncCallback[(A, B)]
  66. def zipWith[B, C](that: AsyncCallback[B])(f: (A, B) => C): AsyncCallback[C]
  67. def |>[B](f: (A) => B): AsyncCallback[B]

    Alias for map.

    Alias for map.

    Annotations
    @inline()

Inherited from AnyVal

Inherited from Any

Ungrouped