I wonder if anybody has played with integrating Fl...
# coroutines
I wonder if anybody has played with integrating Flow in iOS Combine - perhaps something like flow.observeAsPublisher() or similar shortcut…
Started down that path (described in following) but it can definitely be taken further - https://johnoreilly.dev/posts/kotlinmultiplatform-swift-combine_publisher-flow/
associated code was also pushed to https://github.com/joreilly/PeopleInSpace
I thought I may have seen it in one of your projects. Great resource, btw. I am attempting to get my ViewModels with a MP LiveData/Observable type object (I dont do the repository layer as yet). Will be checkout out the above.
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:
Copy code
@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:
Copy code
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.