合并:将 AnyPublisher<Void, Error> 转换为 AnyPublisher<"OurType",错误>

Combine: Casting AnyPublisher<Void, Error> to AnyPublisher<"OurType", Error>

我需要测试代码:

func ourFunc() -> AnyPublisher<Void, Never> {
       model: OurModel = OurModel()
       Just(model).eraseToAnyPublisher()
    }

出现错误: Cannot convert value of type OurModel to expected type Void

我们如何将 OurModel 类型转换为 Void

我看不出有任何意义。你能进一步解释一下吗?

映射它没有意义……

Just(model).map { _ in } .eraseToAnyPublisher()

…因为原来的 Output 是什么并不重要。都会变成().

Just(()).eraseToAnyPublisher()