Skip to content

Commit feee88e

Browse files
committed
Add priority to async fireAndForget. (#1084)
* Add priority to async fireAndForget. * actually use priority
1 parent 64bc936 commit feee88e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Sources/ComposableArchitecture/Effects/Concurrency.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,21 @@ import ReactiveSwift
102102
return producer.on(disposed: task?.cancel)
103103
}
104104
}
105+
106+
/// Creates an effect that executes some work in the real world that doesn't need to feed data
107+
/// back into the store.
108+
///
109+
/// - Parameters:
110+
/// - priority: Priority of the underlying task. If `nil`, the priority will come from
111+
/// `Task.currentPriority`.
112+
/// - work: A closure encapsulating some work to execute in the real world.
113+
/// - Returns: An effect.
114+
public static func fireAndForget(
115+
priority: TaskPriority? = nil,
116+
_ work: @escaping @Sendable () async -> Void
117+
) -> Effect {
118+
Effect<Void, Never>.task(priority: priority) { await work() }
119+
.fireAndForget()
120+
}
105121
}
106122
#endif

0 commit comments

Comments
 (0)