Instance Method

filter(_:)

Republishes all elements that match a provided closure.

Declaration

func filter(_ isIncluded: @escaping (Self.Output) -> Bool) -> Publishers.Filter<Self>

Parameters

isIncluded

A closure that takes one element and returns a Boolean value indicating whether to republish the element.

Return Value

A publisher that republishes all elements that satisfy the closure.

See Also

Filtering Elements

func tryFilter((Self.Output) -> Bool) -> Publishers.TryFilter<Self>

Republishes all elements that match a provided error-throwing closure.

func compactMap<T>((Self.Output) -> T?) -> Publishers.CompactMap<Self, T>

Calls a closure with each received element and publishes any returned optional that has a value.

func tryCompactMap<T>((Self.Output) -> T?) -> Publishers.TryCompactMap<Self, T>

Calls an error-throwing closure with each received element and publishes any returned optional that has a value.

func removeDuplicates() -> Publishers.RemoveDuplicates<Self>

Publishes only elements that don’t match the previous element.

func removeDuplicates(by: (Self.Output, Self.Output) -> Bool) -> Publishers.RemoveDuplicates<Self>

Publishes only elements that don’t match the previous element, as evaluated by a provided closure.

func tryRemoveDuplicates(by: (Self.Output, Self.Output) -> Bool) -> Publishers.TryRemoveDuplicates<Self>

Publishes only elements that don’t match the previous element, as evaluated by a provided error-throwing closure.

func replaceEmpty(with: Self.Output) -> Publishers.ReplaceEmpty<Self>

Replaces an empty stream with the provided element.

func replaceError(with: Self.Output) -> Publishers.ReplaceError<Self>

Replaces any errors in the stream with the provided element.