@@ -131,41 +131,27 @@ extension Effect {
131
131
/// and any failure.
132
132
///
133
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.
134
+ /// into the system. It can automatically promote an effect to your reducer's domain.
135
135
///
136
136
/// case .buttonTapped:
137
137
/// return analyticsClient.track("Button Tapped")
138
138
/// .fireAndForget()
139
139
///
140
+ /// - Parameters:
141
+ /// - outputType: An output type.
142
+ /// - failureType: A failure type.
140
143
/// - Returns: An effect that never produces output or errors.
141
- public func fireAndForget< NewValue, NewError> ( ) -> Effect < NewValue , NewError > {
144
+ public func fireAndForget< NewValue, NewError> (
145
+ outputType: NewValue . Type = NewValue . self,
146
+ failureType: NewError . Type = NewError . self
147
+ ) -> Effect < NewValue , NewError > {
142
148
self . flatMapError { _ in . empty }
143
149
. flatMap ( . latest) { _ in
144
150
. empty
145
151
}
146
152
}
147
153
}
148
154
149
- extension Effect where Value == Never {
150
- /// Upcasts an `Effect<Never, Error>` to an `Effect<T, Error>` for any type `T`. This is
151
- /// possible to do because an `Effect<Never, Error>` can never produce any values to feed back
152
- /// into the store (hence the name "fire and forget"), and therefore we can act like it's an
153
- /// effect that produces values of any type (since it never produces values).
154
- ///
155
- /// This is useful for times you have an `Effect<Never, Error>` but need to massage it into
156
- /// another type in order to return it from a reducer:
157
- ///
158
- /// case .buttonTapped:
159
- /// return analyticsClient.track("Button Tapped")
160
- /// .fireAndForget()
161
- ///
162
- /// - Returns: An effect.
163
- public func fireAndForget< T> ( ) -> Effect < T , Error > {
164
- func absurd< A> ( _ never: Never ) -> A { }
165
- return self . map ( absurd)
166
- }
167
- }
168
-
169
155
extension Effect where Self. Error == Never {
170
156
171
157
/// Assigns each element from an Effect to a property on an object.
0 commit comments