Skip to content

Commit a6d3a2f

Browse files
committed
Remove redundant 'toFuture' method.
1 parent a197d42 commit a6d3a2f

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

modules/api/js/src/main/scala/tausi/api/event.scala

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -226,16 +226,9 @@ object event:
226226
)
227227

228228
val jsPromise = TIG.invoke[Int]("plugin:event|listen", args, InvokeOptionsJS.empty)
229-
val p = scala.concurrent.Promise[EventHandle]()
230-
jsPromise.`then`[Unit](
231-
(eventIdentifier: Int) => p.success(EventHandle(name, EventId.unsafe(eventIdentifier), callbackId)): Unit,
232-
(error: Any) =>
233-
val throwable = error match
234-
case t: Throwable => t
235-
case _ => js.JavaScriptException(error)
236-
p.failure(throwable): Unit
237-
): Unit
238-
p.future
229+
jsPromise.toFuture.map { eventIdentifier =>
230+
EventHandle(name, EventId.unsafe(eventIdentifier), callbackId)
231+
}
239232
end registerListener
240233

241234
private def unlistenInternal(

0 commit comments

Comments
 (0)