John, thank you for the links. I spent a couple days banging on this, and have made progress in making it a little more generic. Not as clean (yet) as I would like, but it looks like this:
@available(iOS 13.0, *)
struct FlowPublisher<Output: NSObject>: Publisher {
typealias Failure = Never
var wrapper: FlowWrapper<Output>
// Publisher protocol
func receive<S>(subscriber: S) where S : Subscriber, Self.Failure == S.Failure, Self.Output == S.Input {
let subscription = FlowSubscription(wrapper: wrapper, subscriber: subscriber)
subscriber.receive(subscription: subscription)
}
}
and then used like so:
FlowPublisher<KotlinBoolean>(wrapper: viewModel.nativeLoading)
.map { $0.boolValue }
.receive(on: DispatchQueue.main)
.assign(to: \.isLoading, on: self)
.store(in: &cancellables)
Perhaps after I get it cleaned up a bit more, I will share it more widely. Thanks again.