Skip to content

Commit

Permalink
Merge pull request #2845 from armanbilge/doc/unsafeToPromise
Browse files Browse the repository at this point in the history
Add scaladoc for `IO#unsafeToPromise`
  • Loading branch information
armanbilge authored Feb 27, 2022
2 parents 90b0205 + 1a5667a commit 405fa89
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/js/src/main/scala/cats/effect/IOPlatform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ import scala.scalajs.js.{|, Function1, JavaScriptException, Promise, Thenable}

abstract private[effect] class IOPlatform[+A] { self: IO[A] =>

/**
* Evaluates the effect and produces the result in a JavaScript `Promise`.
*
* This is similar to `unsafeRunAsync` in that it evaluates the `IO` as a side effect in a
* non-blocking fashion, but uses a `Promise` rather than an explicit callback. This function
* should really only be used if interoperating with code which uses JavaScript promises.
*
* @see
* [[IO.fromPromise]]
*/
def unsafeToPromise()(implicit runtime: unsafe.IORuntime): Promise[A] =
new Promise[A]((resolve: Function1[A | Thenable[A], _], reject: Function1[Any, _]) =>
self.unsafeRunAsync {
Expand Down

0 comments on commit 405fa89

Please sign in to comment.