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: - >>=() / 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).
The type of data asynchronously produced on success.
A => CallbackTo[B]
aka Kleisli[CallbackTo, A, B]
aka ReaderT[A, CallbackTo, B]
.
A => CallbackTo[B]
aka Kleisli[CallbackTo, A, B]
aka ReaderT[A, CallbackTo, B]
.
Never heard of Kleisli? Basically, a "Kleisli triple" is a function with the shape A => M[B]
.
In this case, the M
is hard-coded to CallbackTo
.
This is hard-coded to CallbackTo
for the same reasons as CallbackOption
and for the same reasons that CallbackTo exists.
1.2.0
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 Scalaz or similar.
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 Scalaz).
() => Unit
is replaced by Callback
.
Similarly, ReactEvent => Unit
is replaced by ReactEvent => Callback
.
The type of result produced when the callback is invoked.
0.10.0
Describes how a component uses .props.children
.
Extensions to plain old DOM.
Extensions to plain old DOM.
Tests whether one instance can be used in place of another.
Tests whether one instance can be used in place of another. Used mostly to compare properties and state of a component to avoid unnecessary updates.
If you imagine a class with 8 fields, equality would compare all 8 fields where as this would typically just compare the ID field, the update-date, or the revision number. You might think of this as a very quick version of equality.
Don't miss Reusability.shouldComponentUpdate
which can be applied to a component via
ScalaComponent.build#configure
.
0.9.0
A value that has been explicitly paired with a (potentially ad-hoc) Reusability instance.
A value that has been explicitly paired with a (potentially ad-hoc) Reusability instance.
The type of value.
1.0.0
Base class for something that has read/write state access (under the same effect type).
Base class for something that has read/write state access (under the same effect type).
Passing this around (top-level) is fine but do not use it in a generic/library/helper method. In intermediary positions, use StateAccessor instead.
The type of effect when accessing state.
State type.
A callback with no return value.
A callback with no return value. Equivalent to () => Unit
.
CallbackTo
Type-classes that provide read and/or write access to state.
Type-classes that provide read and/or write access to state.
The syntax is a little wonky for technical reasons.
For read access, it's typeclass.state(i): F[S]
.
For write access, it's typeclass(i).setState(...): F[Unit]
.
See https://flow.org/en/docs/react/types