Closed diegoventura closed 4 years ago
You could try -
extension Promise {
public func resolveOnMainThread() -> Promise<T> {
return Promise<T> { resolve, reject, progress in
self.progress { p in
DispatchQueue.main.async {
progress(p)
}
}
self.registerThen { t in
DispatchQueue.main.async {
resolve(t)
}
}
self.onError { e in
DispatchQueue.main.async {
reject(e)
}
}
}
}
}
@diegoventura Indeed this is implemented in the ws library https://github.com/freshOS/ws. You can easily implement it with the code above shared by @nodediggity :)
@@diegoventura Did that work out for you? can we close this?
Yes! Thanks and sorry for late response
👋
Is there a way to resolve a promise on the main thread?
I saw a
resolveOnMainThread()
on the readme, but couldn't find any reference to it in the source code.Thanks