tylerwilson
01/07/2021, 5:15 PMJohn O'Reilly
01/07/2021, 5:24 PMJohn O'Reilly
01/07/2021, 5:46 PMtylerwilson
01/07/2021, 5:51 PMtylerwilson
01/13/2021, 1:33 AM@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.