An extension of ECNetworking.
.package(url: "https://github.com/EvanCooper9/RxECNetworking", from: "2.0.0")
Sending requests is reactive. Only the syntax is changed.
let request = ListUsersRequest(online: true)
network.send(request)
.subscribe(onSuccess: { users in
showUsers(users)
})
.disposed(by: disposeBag)
Actions are also reactive, all action protocols gain an Rx
prefix, and require a DisposeBag
.
struct AuthenticationAction: RxRequestWillBeginAction {
let disposeBag = DisposeBag()
func requestWillBegin(_ request: NetworkRequest) -> Single<NetworkRequest>
guard request.requiresAuthentication else { .just(request) }
// add authentication headers
return .just(request)
}
}