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 @@ -126,6 +126,24 @@ extension Effect {
126
126
self . map ( Result< Value, Error> . success)
127
127
. flatMapError { Effect < Result < Value , Error > , Never > ( value: Result . failure ( $0) ) }
128
128
}
129
+
130
+ /// Turns any publisher into an `Effect` for any output and failure type by ignoring all output
131
+ /// and any failure.
132
+ ///
133
+ /// This is useful for times you want to fire off an effect but don't want to feed any data back
134
+ /// into the system.
135
+ ///
136
+ /// case .buttonTapped:
137
+ /// return analyticsClient.track("Button Tapped")
138
+ /// .fireAndForget()
139
+ ///
140
+ /// - Returns: An effect that never produces output or errors.
141
+ public func fireAndForget< NewValue, NewError> ( ) -> Effect < NewValue , NewError > {
142
+ self . flatMapError { _ in . empty }
143
+ . flatMap ( . latest) { _ in
144
+ . empty
145
+ }
146
+ }
129
147
}
130
148
131
149
extension Effect where Value == Never {
You can’t perform that action at this time.
0 commit comments