mirror of
https://github.com/maxgoedjen/secretive.git
synced 2026-03-10 19:47:24 +01:00
Add main actor trampolines
This commit is contained in:
17
Sources/Secretive/Helpers/MainActorWrappers.swift
Normal file
17
Sources/Secretive/Helpers/MainActorWrappers.swift
Normal file
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user