File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Sources/ComposableArchitecture Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -333,4 +333,22 @@ extension Publisher {
333333 . catch { Just ( . failure( $0) ) }
334334 . eraseToEffect ( )
335335 }
336+
337+ /// Turns any publisher into an `Effect` for any output and failure type by ignoring all output
338+ /// and any failure.
339+ ///
340+ /// This is useful for times you want to fire off an effect but don't want to feed any data back
341+ /// into the system.
342+ ///
343+ /// case .buttonTapped:
344+ /// return analyticsClient.track("Button Tapped")
345+ /// .fireAndForget()
346+ ///
347+ /// - Returns: An effect that never produces output or errors.
348+ public func fireAndForget< NewOutput, NewFailure> ( ) -> Effect < NewOutput , NewFailure > {
349+ return self
350+ . flatMap { _ in Empty ( ) }
351+ . catch { _ in Empty ( ) }
352+ . eraseToEffect ( )
353+ }
336354}
You can’t perform that action at this time.
0 commit comments