Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swap Thenable for Promise in Async.fromPromise #2237

Merged
merged 2 commits into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/js/src/main/scala/cats/effect/IOCompanionPlatform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package cats.effect

import scalajs.js

import scala.scalajs.js.Promise
import scala.scalajs.js.Thenable

private[effect] abstract class IOCompanionPlatform { this: IO.type =>

Expand All @@ -35,7 +35,7 @@ private[effect] abstract class IOCompanionPlatform { this: IO.type =>
apply(thunk)
}

def fromPromise[A](iop: IO[Promise[A]]): IO[A] =
def fromPromise[A](iop: IO[Thenable[A]]): IO[A] =
asyncForIO.fromPromise(iop)

def realTimeDate: IO[js.Date] = asyncForIO.realTimeDate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

package cats.effect.kernel

import scala.scalajs.js.{|, defined, Function1, JavaScriptException, Promise, Thenable}
import scala.scalajs.js.{|, defined, Function1, JavaScriptException, Thenable}

private[kernel] trait AsyncPlatform[F[_]] { this: Async[F] =>

def fromPromise[A](iop: F[Promise[A]]): F[A] =
def fromPromise[A](iop: F[Thenable[A]]): F[A] =
flatMap(iop) { p =>
async_[A] { cb =>
val onFulfilled: Function1[A, Unit | Thenable[Unit]] =
Expand Down