Publisher
extension Publisher
-
Turns any publisher into an
Effect
.This can be useful for when you perform a chain of publisher transformations in a reducer, and you need to convert that publisher to an effect so that you can return it from the reducer:
case .buttonTapped: return fetchUser(id: 1) .filter(\.isAdmin) .eraseToEffect()
Declaration
Swift
public func eraseToEffect() -> Effect<Output, Failure>
Return Value
An effect that wraps
self
. -
Turns any publisher into an
Effect
that cannot fail by wrapping its output and failure in a result.This can be useful when you are working with a failing API but want to deliver its data to an action that handles both success and failure.
case .buttonTapped: return fetchUser(id: 1) .catchToEffect() .map(ProfileAction.userResponse)
Declaration
Swift
public func catchToEffect() -> Effect<Result<Output, Failure>, Never>
Return Value
An effect that wraps
self
.