Effect

public struct Effect

Configures an Effect from a source function and a dispatch option.

Effects are used for side-effects in ReCombine applications. See the Architecture section of the official documentation for more.

let successEffect = Effect(dispatch: false) { (actions: AnyPublisher<Action, Never>) -> AnyPublisher<Action, Never> in
   actions
    .ofType(GetPostsSuccess.self)
    .handleEvents(receiveOutput: { _ in print("Got it") })
    .eraseActionType()
    .eraseToAnyPublisher()
}
  • When true, the emitted actions from the source Action Publisher will be dispatched to the store. If false, the emitted actions will be ignored.

    Declaration

    Swift

    public let dispatch: Bool
  • A closure with takes in an Action Publisher and returns an Action Publisher

    Declaration

    Swift

    public let source: (AnyPublisher<Action, Never>) -> AnyPublisher<Action, Never>
  • Initializes an Effect

    Declaration

    Swift

    public init(dispatch: Bool, _ source: @escaping (AnyPublisher<Action, Never>) -> AnyPublisher<Action, Never>)