private let bag = DisposeBag() @RxPublished private(set) var isLoading = false @RxPublished private(set) var products: [Product] = [] func load() { useCase .products() .do( onSuccess: { [unowned self] _ in self.isLoading = false }, onError: { [unowned self] error in self.isLoading = false // Handle error }, onSubscribe: { [unowned self] in self.isLoading = true } ) // subscribe .assign(to: \.products, on: self) .disposed(by: bag) } } extension PrimitiveSequence where Trait == SingleTrait { func assign<Root>(to keyPath: ReferenceWritableKeyPath<Root, Element>, on object: Root) -> Disposable { return subscribe(onSuccess: { object[keyPath: keyPath] = $0 }) } } ˞BTTJHO FYUFOTJPO͍ͯ͠·͢