final class JSPromiseOps[A] extends AnyVal
More ergonomic typed methods for js.Promise processing. Should just convert to Future
as the overhead is *not* that much and its much easier to use. You should not import the
implicit converters for js.Promise if you want to use map/flatMap on the promise itself:
import scala.scalajs.js.Thenable.Implicits._
- Alphabetic
- By Inheritance
- JSPromiseOps
- AnyVal
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- Any
- final def ##: Int
- Definition Classes
- Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- Any
- def as[B](b: B): Thenable[B]
Sequence computation, then replace final values with
b
. - final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def asPromise: Promise[A]
Cast since these js effect types get a bit screwed up in scala-js.
- def collect[S](pf: PartialFunction[A, S]): Thenable[S]
Not sure this is semantically right...
- def either: Thenable[Either[Any, A]]
While the result is still wrapped in a promise effect, the error has been pushed into
Either
. - def failed: Thenable[Any]
If this fails, push the error into the value position of the promise.
- def fallbackTo[U >: A](that: Promise[U]): Thenable[U]
Return this if it succeeds otherwise return that.
Return this if it succeeds otherwise return that. If that fails, return failure from this.
- def filter(p: (A) => Boolean): Thenable[A]
Filter on the value.
Filter on the value. Return failed Thenable with NoSuchElementException if p => false.
- def flatMap[B](f: (A) => Thenable[B]): Thenable[B]
flatMap
- def flatMapError(f: (Any) => Thenable[Any]): Thenable[A]
Map on error.
Map on error. Use the value in the effect and redirect to the error in self. Any error in
f
is ignored. - def flatten[S](implicit ev: <:<[A, Thenable[S]]): Thenable[S]
- def foreach[U](f: (A) => U): Thenable[U]
Unlike
Future.foreach
, return an effect after runningf
.Unlike
Future.foreach
, return an effect after runningf
. It's liketapValue
. - def getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def jsCatch(f: (Any) => Any): Thenable[A]
Transform the rejected value to another value which is also rejected.
- def jsCatchF[B](f: (Any) => Thenable[B]): Thenable[B]
Transform the rejected value to a Thenable, which may be rejected or resolved.
- def jsThen[B >: A](onFulfilled: (A) => B, onRejected: (Any) => B): Thenable[B]
co-map
- def jsThen[B](f: (A) => B): Thenable[B]
map
- def jsThenF[B](onFulfilled: (A) => Thenable[B], onRejected: (Any) => Thenable[B]): Thenable[B]
co-flatMap
- def jsThenF[B](f: (A) => Thenable[B]): Thenable[B]
flatMap
- def map[B](f: (A) => B): Thenable[B]
map
- def mapError(f: (Any) => Any): Thenable[A]
Map on error.
- def mapTo[S](implicit tag: ClassTag[S]): Thenable[S]
Cast to S otherwise throw a ClassCastException.
- def opt: Thenable[Option[A]]
Push the value into
Option
and the error into None.Push the value into
Option
and the error into None. The result is still wrapped in an effect. - def orElse[B >: A](that: => Thenable[B]): Thenable[B]
Return this value if successful, else that's value.
- def recover[U >: A](pf: PartialFunction[Any, U]): Thenable[U]
Recover from the error using a partial function.
Recover from the error using a partial function. If the partial function is defined at the value, then the function is applied. Otherwise the original value or error remains. recover = catch.
- def recoverWith[U >: A](pf: PartialFunction[Any, Thenable[U]]): Thenable[U]
Like
recover
but the partial function returns ajs.Thenable
.Like
recover
but the partial function returns ajs.Thenable
. recover = catch. - def tapError(f: (Any) => Unit): Thenable[A]
Tap into the error.
- def tapErrorF(f: (Any) => Thenable[Unit]): Thenable[A]
- def tapValue(f: (A) => Unit): Thenable[A]
Tap into the result.
- def tapValueF[U >: A](f: (U) => Thenable[U]): Thenable[U]
Tap into the result.
- def toString(): String
- Definition Classes
- Any
- def transform[S](f: (Try[A]) => Try[S]): Thenable[S]
Not sure this is semantically right...
- def transform[U](s: (A) => U, f: (Any) => Any): Thenable[U]
Map over the resolved value or the error.
- def unit: Thenable[Unit]
Map the resolved value to unit.
Map the resolved value to unit. Otherwise the error falls through.
- def withFilter(p: (A) => Boolean): Thenable[A]
for-comprehension support.