c

jshelpers

JSPromiseOps

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._

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. JSPromiseOps
  2. AnyVal
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new JSPromiseOps(self: Thenable[A])

Type Members

  1. type REJECTED[A] = Function1[Any, RVAL[A]]
  2. type RESOLVE[A, B] = Function1[A, RVAL[B]]
  3. type RVAL[A] = |[A, Thenable[A]]

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    Any
  2. final def ##: Int
    Definition Classes
    Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    Any
  4. def as[B](b: B): Thenable[B]

    Sequence computation, then replace final values with b.

  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def asPromise: Promise[A]

    Cast since these js effect types get a bit screwed up in scala-js.

  7. def collect[S](pf: PartialFunction[A, S]): Thenable[S]

    Not sure this is semantically right...

  8. def either: Thenable[Either[Any, A]]

    While the result is still wrapped in a promise effect, the error has been pushed into Either.

  9. def failed: Thenable[Any]

    If this fails, push the error into the value position of the promise.

  10. 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.

  11. def filter(p: (A) => Boolean): Thenable[A]

    Filter on the value.

    Filter on the value. Return failed Thenable with NoSuchElementException if p => false.

  12. def flatMap[B](f: (A) => Thenable[B]): Thenable[B]

    flatMap

  13. 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.

  14. def flatten[S](implicit ev: <:<[A, Thenable[S]]): Thenable[S]
  15. def foreach[U](f: (A) => U): Thenable[U]

    Unlike Future.foreach, return an effect after running f.

    Unlike Future.foreach, return an effect after running f. It's like tapValue.

  16. def getClass(): Class[_ <: AnyVal]
    Definition Classes
    AnyVal → Any
  17. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  18. def jsCatch(f: (Any) => Any): Thenable[A]

    Transform the rejected value to another value which is also rejected.

  19. def jsCatchF[B](f: (Any) => Thenable[B]): Thenable[B]

    Transform the rejected value to a Thenable, which may be rejected or resolved.

  20. def jsThen[B >: A](onFulfilled: (A) => B, onRejected: (Any) => B): Thenable[B]

    co-map

  21. def jsThen[B](f: (A) => B): Thenable[B]

    map

  22. def jsThenF[B](onFulfilled: (A) => Thenable[B], onRejected: (Any) => Thenable[B]): Thenable[B]

    co-flatMap

  23. def jsThenF[B](f: (A) => Thenable[B]): Thenable[B]

    flatMap

  24. def map[B](f: (A) => B): Thenable[B]

    map

  25. def mapError(f: (Any) => Any): Thenable[A]

    Map on error.

  26. def mapTo[S](implicit tag: ClassTag[S]): Thenable[S]

    Cast to S otherwise throw a ClassCastException.

  27. 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.

  28. def orElse[B >: A](that: => Thenable[B]): Thenable[B]

    Return this value if successful, else that's value.

  29. 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.

  30. def recoverWith[U >: A](pf: PartialFunction[Any, Thenable[U]]): Thenable[U]

    Like recover but the partial function returns a js.Thenable.

    Like recover but the partial function returns a js.Thenable. recover = catch.

  31. def tapError(f: (Any) => Unit): Thenable[A]

    Tap into the error.

  32. def tapErrorF(f: (Any) => Thenable[Unit]): Thenable[A]
  33. def tapValue(f: (A) => Unit): Thenable[A]

    Tap into the result.

  34. def tapValueF[U >: A](f: (U) => Thenable[U]): Thenable[U]

    Tap into the result.

  35. def toString(): String
    Definition Classes
    Any
  36. def transform[S](f: (Try[A]) => Try[S]): Thenable[S]

    Not sure this is semantically right...

  37. def transform[U](s: (A) => U, f: (Any) => Any): Thenable[U]

    Map over the resolved value or the error.

  38. def unit: Thenable[Unit]

    Map the resolved value to unit.

    Map the resolved value to unit. Otherwise the error falls through.

  39. def withFilter(p: (A) => Boolean): Thenable[A]

    for-comprehension support.

Inherited from AnyVal

Inherited from Any

Ungrouped