Go to file
Zach Eriksen 1b15d134f1 Merge branch 'main' of github.com:0xLeif/FlatMany 2021-05-13 15:48:11 -05:00
.swiftpm/xcode/package.xcworkspace/xcshareddata FlatMany.init 2021-05-13 08:52:07 -05:00
Sources/FlatMany Added compactMap 2021-05-13 15:48:00 -05:00
Tests/FlatManyTests FlatMany.init 2021-05-13 08:52:07 -05:00
.gitignore FlatMany.init 2021-05-13 08:52:07 -05:00
LICENSE Initial commit 2021-05-13 08:50:09 -05:00
Package.swift FlatMany.init 2021-05-13 08:52:07 -05:00
README.md Update README.md 2021-05-13 10:18:16 -05:00

README.md

FlatMany

flatMap --> Publishers.MergeMany --> map --> collect

What does FlatMany do?

When you have a Publisher which has an Output that is a sequence. FlatMany makes it easy to map each element of that sequence into a publisher.

Usage

import FlatMany

Example

let task = Just<[Int]>([1, 2, 3])
    .flatMany {
        Just("\($0 * $0)").eraseToAnyPublisher()
    }
    .sink { values in
        print(values)
    }