For building Callback objects using the Partially-Applied Type technique.
For building Callback objects using the Partially-Applied Type technique.
For example these are Equivalent:
Callback[Throwable, Throwable].empty[String] <-> Callback.empty[Throwable, String]
Creates an empty Callback, a callback that doesn't do
anything in onNext
and that logs errors in onError
with
the provided monix.execution.UncaughtExceptionReporter.
Given a Callback wraps it into an implementation that
calls onSuccess
and onError
asynchronously, using the
given scala.concurrent.ExecutionContext.
Given a Callback wraps it into an implementation that
calls onSuccess
and onError
asynchronously, using the
given scala.concurrent.ExecutionContext.
The async boundary created is "light", in the sense that a TrampolinedRunnable is used and supporting schedulers can execute these using an internal trampoline, thus execution being faster and immediate, but still avoiding growing the call-stack and thus avoiding stack overflows.
THREAD-SAFETY: the returned callback is thread-safe.
In case onSuccess
and onError
get called multiple times,
from multiple threads even, the implementation protects against
access violations and throws a
CallbackCalledMultipleTimesException.
Turns Either[Throwable, A] => Unit
callbacks into Monix
callbacks.
Turns Either[Throwable, A] => Unit
callbacks into Monix
callbacks.
These are common within Cats' implementation, used for
example in cats.effect.IO
.
WARNING: the returned callback is NOT thread-safe!
Returns a Callback instance that will complete the given promise.
Returns a Callback instance that will complete the given promise.
THREAD-SAFETY: the provided instance is thread-safe by virtue
of Promise
being thread-safe.
Turns Try[A] => Unit
callbacks into Monix callbacks.
Turns Try[A] => Unit
callbacks into Monix callbacks.
These are common within Scala's standard library implementation,
due to usage with Scala's Future
.
WARNING: the returned callback is NOT thread-safe!
Wraps any Callback into a safer implementation that protects against protocol violations (e.g.
Wraps any Callback into a safer implementation that
protects against protocol violations (e.g. onSuccess
or onError
must be called at most once).
THREAD-SAFETY: the returned callback is thread-safe.
In case onSuccess
and onError
get called multiple times,
from multiple threads even, the implementation protects against
access violations and throws a
CallbackCalledMultipleTimesException.
Given a Callback wraps it into an implementation that
calls onSuccess
and onError
asynchronously, using the
given scala.concurrent.ExecutionContext.
Given a Callback wraps it into an implementation that
calls onSuccess
and onError
asynchronously, using the
given scala.concurrent.ExecutionContext.
The async boundary created is "light", in the sense that a TrampolinedRunnable is used and supporting schedulers can execute these using an internal trampoline, thus execution being faster and immediate, but still avoiding growing the call-stack and thus avoiding stack overflows.
THREAD-SAFETY: the returned callback is thread-safe.
In case onSuccess
and onError
get called multiple times,
from multiple threads even, the implementation protects against
access violations and throws a
CallbackCalledMultipleTimesException.