Publisher

public extension Publisher where Output == Action

Operators for narrowing down Actions in Publisher streams.

Available where Output == Action

  • Only lets Actions of a certain type get through the stream.

    actions
        .ofType(FetchTodosAction.self)
        .sink(receiveValue: { action in
            print("This is a FetchTodosAction: \(action)")
        })
    

    Declaration

    Swift

    func ofType<T>(_ typeToMatch: T.Type) -> AnyPublisher<T, Self.Failure>

    Parameters

    typeToMatch

    A type of Action to match

  • Only lets Actions created from the given ActionTemplates get through the stream.

    actions
        .wasCreated(from: fetchTodosActionTemplate)
        .sink(receiveValue: { action in
            print("This is a FetchTodosAction: \(action)")
        })
    

    Declaration

    Swift

    func wasCreated<Payload>(from actionTemplate: ActionTemplate<Payload>)
        -> AnyPublisher<AnonymousAction<Payload>, Self.Failure>

    Parameters

    actionTemplate

    An ActionTemplate to check

  • Only lets AnonymousActions with a certain identifier get through the stream.

    actions
        .withIdentifier("FetchTodosAction")
        .sink(receiveValue: { action in
            print("This is an AnonymousAction with the id 'FetchTodosAction': \(action)")
        })
    

    Declaration

    Swift

    func withIdentifier(_ identifierToMatch: String) -> AnyPublisher<Action, Self.Failure>

    Parameters

    identifierToMatch

    A identifier to match