Sometimes it's necessary to construct a large, complex publisher and return it from a function. Currently you either need to explicitly return that type from the function, which is difficult and breaks compilation with any change to the publisher:
func onAppearEffects() -> Publishers.Zip<...> {
fetchUser()
.zip(with: fetchRespositories())
.zip(with: fetchFavorites())
}
Or you have to erase the publisher:
func onAppearEffects() -> AnyPublisher<Action, Never> {
fetchUser()
.zip(with: fetchRespositories())
.zip(with: fetchFavorites())
.eraseToAnyPublisher()
}
If Publisher
had primary associated types then you could use some Publisher
:
func onAppearEffects() -> some Publisher<Action, Never> {
fetchUser()
.zip(with: fetchRespositories())
.zip(with: fetchFavorites())
}