Skip to content

Commit e87590d

Browse files
committed
Remove old Effect.fireAndForget() (#430)
1 parent ee13d74 commit e87590d

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed

Sources/ComposableArchitecture/Effect.swift

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -131,41 +131,27 @@ extension Effect {
131131
/// and any failure.
132132
///
133133
/// 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.
135135
///
136136
/// case .buttonTapped:
137137
/// return analyticsClient.track("Button Tapped")
138138
/// .fireAndForget()
139139
///
140+
/// - Parameters:
141+
/// - outputType: An output type.
142+
/// - failureType: A failure type.
140143
/// - 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> {
142148
self.flatMapError { _ in .empty }
143149
.flatMap(.latest) { _ in
144150
.empty
145151
}
146152
}
147153
}
148154

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-
169155
extension Effect where Self.Error == Never {
170156

171157
/// Assigns each element from an Effect to a property on an object.

0 commit comments

Comments
 (0)