Callback

object Callback

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

See also

CallbackTo

class Object
trait Matchable
class Any

Type members

Classlikes

@implicitNotFound("You\'re wrapping a ${A} in a Callback which will discard without running it. Instead use CallbackTo(…).flatten or Callback{,To}.lazily(…).")
final class ResultGuard[A]
Companion
object
object ResultGuard
Companion
class
final class SetIntervalResult(val handle: SetIntervalHandle)
final class SetTimeoutResult(val handle: SetTimeoutHandle)

Value members

Concrete methods

inline def alert(message: String): Callback

Convenience for calling dom.alert.

Convenience for calling dom.alert.

inline def apply[A](inline f: A)(using inline ev: ResultGuard[A]): Callback
inline def assert(test: Boolean, message: String, optionalParams: Any*): Callback

Convenience for calling dom.console.assert.

Convenience for calling dom.console.assert.

inline def fromJsFn(f: Function0[Unit]): Callback
inline def future[A](inline f: Future[CallbackTo[A]])(implicit ec: ExecutionContext): Callback

Wraps a Future so that it is repeatable, and so that its inner callback is run when the future completes.

Wraps a Future so that it is repeatable, and so that its inner callback is run when the future completes.

The result is discarded. To retain it, use CallbackTo.future instead.

Because the Future is discarded, when an exception causes it to fail, the exception is re-thrown. If you want the exception to be ignored or handled differently, use CallbackTo.future instead and then .void to discard the future and turn the result into a Callback.

WARNING: Futures are scheduled to run as soon as they're created. Ensure that the argument you provide creates a new Future; don't reference an existing one.

inline def info(message: Any, optionalParams: Any*): Callback

Convenience for calling dom.console.info.

Convenience for calling dom.console.info.

inline def lazily(inline f: Callback): Callback

Callback that isn't created until the first time it is used, after which it is reused.

Callback that isn't created until the first time it is used, after which it is reused.

inline def lift(f: () => Unit): Callback
inline def log(message: Any, optionalParams: Any*): Callback

Convenience for calling dom.console.log.

Convenience for calling dom.console.log.

def runAll(callbacks: CallbackTo[Any]*): Callback

Run all given callbacks.

Run all given callbacks.

All results are discarded. Any exceptions get a printStackTrace and are then discarded, and the next callback run.

Since

2.0.0

inline def sequence[T <: ([X] =>> Iterable[X]), A](inline tca: T[CallbackTo[A]]): Callback
inline def sequenceOption[A](inline oca: Option[CallbackTo[A]]): Callback
inline def suspend(inline f: Callback): Callback

Callback that is recreated each time it is used.

Callback that is recreated each time it is used.

inline def throwException(t: Throwable): Callback
def traverse[T <: ([X] =>> Iterable[X]), A, B](ta: => T[A])(f: A => CallbackTo[B]): Callback
def traverseOption[A, B](oa: => Option[A])(f: A => CallbackTo[B]): Callback
inline def unless[A](inline cond: Boolean)(inline c: CallbackTo[A]): Callback

Convenience for applying a condition to a callback, and returning Callback.empty when the condition is already satisfied.

Convenience for applying a condition to a callback, and returning Callback.empty when the condition is already satisfied.

Notice the condition is strict. If non-strictness is desired use callback.unless(cond).

Value Params
cond

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

inline def warn(message: Any, optionalParams: Any*): Callback

Convenience for calling dom.console.warn.

Convenience for calling dom.console.warn.

inline def when[A](inline cond: Boolean)(inline c: CallbackTo[A]): Callback

Convenience for applying a condition to a callback, and returning Callback.empty when the condition isn't satisfied.

Convenience for applying a condition to a callback, and returning Callback.empty when the condition isn't satisfied.

Notice the condition is strict. If non-strictness is desired use callback.when(cond).

Value Params
cond

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

Deprecated methods

@deprecated("", "not really deprecated")

Serves as a temporary placeholder for a callback until you supply a real implementation.

Serves as a temporary placeholder for a callback until you supply a real implementation.

Unlike ??? this doesn't crash, it just prints a warning to the console.

Also it's not really deprecated; that's just so you get a compiler warning as a reminder.

Deprecated
@deprecated("", "not really deprecated")
def TODO(reason: => String): Callback

Serves as a temporary placeholder for a callback until you supply a real implementation.

Serves as a temporary placeholder for a callback until you supply a real implementation.

Unlike ??? this doesn't crash, it just prints a warning to the console.

Also it's not really deprecated; that's just so you get a compiler warning as a reminder.

Deprecated
@deprecated("Use Callback.suspend", "2.0.0")
inline def byName(inline f: Callback): Callback

Callback that is recreated each time it is used.

Callback that is recreated each time it is used.

https://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_name

Deprecated
@deprecated("use throwException", "1.6.1")
inline def error(t: Throwable): Callback
Deprecated

Concrete fields

A callback that does nothing.

A callback that does nothing.