japgolly.scalajs.react.callback

Type members

Classlikes

Companion
class
final class AsyncCallback[+A] extends AnyVal

Pure asynchronous callback.

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:

The following methods are effectively parallel:

In order to actually run this, or get it into a shape in which in can be run, use one of the following:

A good example is the Ajax 2 demo.

Type Params
A

The type of data asynchronously produced on success.

Companion
object
object Callback

A callback with no return value. Equivalent to () => Unit.

A callback with no return value. Equivalent to () => Unit.

See also

CallbackTo

Companion
class
final class CallbackOption[+A](val underlyingRepr: () => A) extends AnyVal

Callback that can short-circuit along the way when conditions you specify, aren't met.

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 Cats or similar.

Companion
object
object CallbackTo
Companion
class
final class CallbackTo[+A](val trampoline: Trampoline[A]) extends AnyVal

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

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 Cats).

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

Type Params
A

The type of result produced when the callback is invoked.

Since

0.10.0

Companion
object
trait Exports
object RateLimit
final class SyncPromise[A]

Promise that is synchronous once its value has been set.

Promise that is synchronous once its value has been set.

Companion
object
object SyncPromise
Companion
class
trait Timer
Companion
object
object Timer
Companion
class
sealed trait Trampoline[+A]
Companion
object
object Trampoline
Companion
class

Types

type Callback = CallbackTo[Unit]