Skip to content

Commit

Permalink
[#515] Remove all Rx things
Browse files Browse the repository at this point in the history
  • Loading branch information
nkhanh44 committed Sep 28, 2023
1 parent 3449d97 commit 9985e09
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 31 deletions.
8 changes: 0 additions & 8 deletions Tuist/Interfaces/UIKit/Project/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ inhibit_all_warnings!
def testing_pods
pod 'Quick'
pod 'Nimble'
pod 'RxNimble', subspecs: ['RxBlocking', 'RxTest']
pod 'RxSwift'
pod 'Sourcery'
pod 'SwiftFormat/CLI'
end
Expand All @@ -16,12 +14,6 @@ target '{PROJECT_NAME}' do
pod 'Kingfisher'
pod 'SnapKit'

# Rx
pod 'RxAlamofire'
pod 'RxCocoa'
pod 'RxDataSources'
pod 'RxSwift'

# Storage
pod 'KeychainAccess'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
//

import Alamofire
import RxAlamofire
import RxSwift
import Combine

protocol NetworkAPIProtocol {

func performRequest<T: Decodable>(_ configuration: RequestConfiguration, for type: T.Type) -> Single<T>
func performRequest<T: Decodable>(
_ configuration: RequestConfiguration,
for type: T.Type
) -> AnyPublisher<T, AFError>
}

extension NetworkAPIProtocol {
Expand All @@ -17,28 +19,16 @@ extension NetworkAPIProtocol {
session: Session,
configuration: RequestConfiguration,
decoder: JSONDecoder
) -> Single<T> {
return session.rx.request(
configuration.method,
) -> AnyPublisher<T, AFError> {
return session.request(
configuration.url,
method: configuration.method,
parameters: configuration.parameters,
encoding: configuration.encoding,
headers: configuration.headers,
interceptor: configuration.interceptor
)
.responseData()
.flatMap { _, data -> Observable<T> in
Observable.create { observer in
do {
let decodable = try decoder.decode(T.self, from: data)
observer.on(.next(decodable))
} catch {
observer.on(.error(error))
}
observer.on(.completed)
return Disposables.create()
}
}
.asSingle()
.publishDecodable(type: T.self, decoder: decoder)
.value()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
//

import Alamofire
import Foundation
import RxSwift
import Combine

final class NetworkAPI: NetworkAPIProtocol {

Expand All @@ -14,7 +13,10 @@ final class NetworkAPI: NetworkAPIProtocol {
self.decoder = decoder
}

func performRequest<T: Decodable>(_ configuration: RequestConfiguration, for type: T.Type) -> Single<T> {
func performRequest<T: Decodable>(
_ configuration: RequestConfiguration,
for type: T.Type
) -> AnyPublisher<T, AFError> {
request(
session: Session(),
configuration: configuration,
Expand Down

0 comments on commit 9985e09

Please sign in to comment.