rx-swift

RxDataSources collection view cell always uses fade for insert cell animation, can't change to a different animation

依然范特西╮ 提交于 2020-01-16 08:35:15
问题 I am having an issue with cell animations using RxSwift on a UICollectionView , my simple setup is as follows: collectionView.register(UINib(nibName: "CustomCollectionCell", bundle: nil), forCellWithReuseIdentifier: "cell") let dataSource = RxCollectionViewSectionedAnimatedDataSource<SectionOfCustomDataAnimated>( animationConfiguration: AnimationConfiguration(insertAnimation: .bottom, reloadAnimation: .bottom, deleteAnimation: .bottom), configureCell: { dataSource, cv, indexPath, element in

Swift 4 “Extra argument in call” Rxswift

筅森魡賤 提交于 2020-01-14 14:20:10
问题 I updated from Swift 3 to 4, and i am using RxSwift, When updated i came across an error "Extra argument in call" as it expects now of type element. I tried creating tuple of (response, data) but still gives me an error as shown. public static func deleteCrush(receiver: String, receiver_type: ProviderType) -> Observable<(HTTPURLResponse, NSArray)> { /* Delete crush identified by `id` */ let parameters: Parameters = [ "receiver": receiver, "receiver_type": receiver_type.rawValue ] print(

RxSwift Shared Subscription Execution Order

ぐ巨炮叔叔 提交于 2020-01-14 10:45:33
问题 How can I ensure that a subscriber to an Observable will receive the onNext event after another subscriber? My example is the following: let firstNameObservable = firstName.asObservable().shareReplay(1) let lastNameObservable = lastName.asObservable().shareReplay(1) let bioObservable = bio.asObservable().shareReplay(1) let websiteObservable = website.asObservable().shareReplay(1) firstNameObservable.subscribe(onNext: { [unowned self] firstName in self.accountDetails.firstName = firstName })

Swift 3 extension constrained to a type

白昼怎懂夜的黑 提交于 2020-01-06 18:57:42
问题 I'd like to extend an RXSwift protocol, namely OsbervableConvertibleType, but I only want to create an extension method only on OsbervableConvertibleTypes, that has a Result object in them. Now, Result is generic again. But I'd like to retain the generic type in my extension function, so the return type of my function is generic as well. Something like this: extension ObservableConvertibleType where E: Result<T> { public func asResultDriver() -> RxCocoa.SharedSequence<RxCocoa

getting error message from server during API call

瘦欲@ 提交于 2020-01-05 04:15:11
问题 I have an app where I used RxSwift for my networking by extending ObservableType this works well but the issue I am having now is when I make an API request and there is an error, I am unable to show the particular error message sent from the server. Now how can I get the particular error response sent from the server extension ObservableType { func convert<T: EVObject>(to observableType: T.Type) -> Observable<T> where E: DataRequest { return self.flatMap({(request) -> Observable<T> in let

How to get error statusCode from `MoyaError`?

我们两清 提交于 2020-01-03 21:09:14
问题 I'm using a Moya , Moya_ModelMapper and RxSwift to perform network requests. Here is my example code: let provider = RxMoyaProvider<MyEndpoint>() let observable: Observable<RegistrationResponse> = provider.request(.register(firstName: "", lastName: "", email: "", password: "")).mapObject(type: RegistrationResponse.self) observable.subscribe { [weak self] (event: Event<RegistrationResponse>) in switch event { case .next(let response): print(response) case .error(let error): print(error) case

How to get error statusCode from `MoyaError`?

≯℡__Kan透↙ 提交于 2020-01-03 21:09:13
问题 I'm using a Moya , Moya_ModelMapper and RxSwift to perform network requests. Here is my example code: let provider = RxMoyaProvider<MyEndpoint>() let observable: Observable<RegistrationResponse> = provider.request(.register(firstName: "", lastName: "", email: "", password: "")).mapObject(type: RegistrationResponse.self) observable.subscribe { [weak self] (event: Event<RegistrationResponse>) in switch event { case .next(let response): print(response) case .error(let error): print(error) case

RxSwift How to add “clear all” UIButton to simple spreadsheet example

穿精又带淫゛_ 提交于 2020-01-03 03:15:05
问题 Here's the code from the RxSwift repo for a simple spreadsheet (adding three numbers): Observable.combineLatest(number1.rx_text, number2.rx_text, number3.rx_text) { textValue1, textValue2, textValue3 -> Int in return (Int(textValue1) ?? 0) + (Int(textValue2) ?? 0) + (Int(textValue3) ?? 0) } .map { $0.description } .bindTo(result.rx_text) .addDisposableTo(disposeBag) I want to add a "Clear all" UIButton, that will cause the three boxes to be reset to zero and the total also set to zero. In

Proper usage of RxSwift to chain requests, flatMap or something else?

喜你入骨 提交于 2020-01-01 03:24:10
问题 First of all, I'm new to rxswift so I guess the answer is obvious however at the moment I can't find solution by myself. I have two functions: func downloadAllTasks() -> Observable<[Task]> func getTaskDetails(taskId: Int64) -> Observable<TaskDetails> First one is downloading the list of Task objects using network request, second one downloading task details for sepcific task (using it's id) What I want of achieve is to download all tasks and then for each task I want to download its details

How to bind rx_tap (UIButton) to ViewModel?

六月ゝ 毕业季﹏ 提交于 2020-01-01 02:47:08
问题 I have authorization controller with 2 UITextField properties and 1 UIButton. I want to bind my View to ViewModel but don't know how to to do it. This is my AuthorizatioVC.swift: class AuthorizationViewController: UIViewController { let disposeBag = DisposeBag() @IBOutlet weak var passwordTxtField: UITextField! @IBOutlet weak var loginTxtField: UITextField! @IBOutlet weak var button: UIButton! override func viewDidLoad() { super.viewDidLoad() addBindsToViewModel() } func addBindsToViewModel()