Skip to content

filterElement to filter inner sequence ? #261

Description

@npvisual

I was wondering if we could add a new function in the SignalProtocol+Sequence.swift file that would allow to filter the elements of a sequence of a signal.

For example :

extension SignalProtocol where Element: Sequence {
    
    /// Filter inner sequence.
    public func filterElement(_ isIncluded: @escaping (Element.Iterator.Element) -> Bool) -> Signal<Element, Error> {
        return self.map { $0.filter(isIncluded) as! Self.Element }
    }
}

... or something along those lines.

Since we already have mapElement, it seems that filterElement is only appropriate (?).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions