[Combine] Chapter 14: In Practice: Project "News". MergeMany custom implementation

Hello @icanzilb ,

Thank you for the snippet with custom MergeMany implementation, looks great! I am wondering if we can start with empty publisher and remove not empty precondition? For example:

    //  let initialPublisher = PassthroughSubject<Story, Error>().eraseToAnyPublisher() // Not sure if this will be better?
    let initialPublisher = Empty<Story, Error>().eraseToAnyPublisher()
    
    return storyIDs.reduce(initialPublisher) { (combined, id) -> AnyPublisher<Story, Error> in
      return combined.merge(with: story(id: id))
        .eraseToAnyPublisher()
    }

Thanks,
Dzmitry.

Hey Dzmitry, looking at the code I don’t see any issue with that - if storyIDs is empty the function just returns Empty() :+1:

1 Like