secretive/Sources/Secretive/Helpers/MainActorWrappers.swift

18 lines
357 B
Swift
Raw Permalink Normal View History

2022-06-08 05:02:49 +00:00
import Foundation
func mainActorWrapped(_ f: @escaping @MainActor () -> Void) -> () -> Void {
return {
DispatchQueue.main.async {
f()
}
}
}
func mainActorWrapped<T: Sendable>(_ f: @escaping @MainActor (T) -> Void) -> (T) -> Void {
return { x in
DispatchQueue.main.async {
f(x)
}
}
}