We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5b50eb4 commit fa0928cCopy full SHA for fa0928c
core/src/main/scala/io/scalajs/util/PromiseHelper.scala
@@ -83,6 +83,19 @@ object PromiseHelper {
83
task
84
}
85
86
+ /**
87
+ * Converts a JavaScript-style callback to a Scala.js promise
88
+ * @param f the given callback function
89
+ * @return a Scala.js promise
90
+ */
91
+ @inline
92
+ def promiseWithError0[Z](f: js.Function1[Z, Any] => Unit): Promise[Unit] = {
93
+ val task = Promise[Unit]()
94
+ f((err: Z) =>
95
+ if (err == null || js.isUndefined(err)) task.success({}) else task.failure(wrapJavaScriptException(err)))
96
+ task
97
+ }
98
+
99
/**
100
* Converts a JavaScript-style callback to a Scala.js promise
101
* @param f the given callback function
0 commit comments