diff --git a/Apexy.podspec b/Apexy.podspec index 932cd8a..00a0b4a 100644 --- a/Apexy.podspec +++ b/Apexy.podspec @@ -29,12 +29,6 @@ Pod::Spec.new do |s| sp.dependency "Apexy/Core" end - s.subspec 'RxSwift' do |sp| - sp.source_files = "Sources/ApexyRxSwift/*.swift" - sp.dependency "Apexy/Core" - sp.dependency "RxSwift", '~>6.0' - end - s.subspec 'Loader' do |sp| sp.source_files = "Sources/ApexyLoader/*.swift" sp.dependency "Apexy/Core" diff --git a/Documentation/reactive.md b/Documentation/reactive.md index 2fde53e..e46d902 100644 --- a/Documentation/reactive.md +++ b/Documentation/reactive.md @@ -1,38 +1,5 @@ # Reactive programming -## Apexy extension for integrating with RxSwift - -If you want to use Apexy with RxSwift add `Apexy/RxSwift` pod to your `Podfile`. - -`pod 'Apexy/RxSwift'` - -How to use by example `BookService` (see Example project). - -```swift -final class BookService { - ... - func fetchBooks() -> Single<[Book]> { - let endpoint = BookListEndpoint() - return apiClient.request(endpoint) - } - ... -} -``` - -```swift -bookService.fetchBooks() - .do(onDispose: { [weak self] in - self?.activityView.isHidden = true - }) - .subscribe(onSuccess: { [weak self] books in - self?.activityView.isHidden = true - self?.show(books: books) - }, onFailure: { [weak self] error in - self?.activityView.isHidden = true - self?.resultLabel.text = error.localizedDescription - }).disposed(by: bag) -``` - ## Combine Apexy supports Combine framework diff --git a/Documentation/reactive.ru.md b/Documentation/reactive.ru.md index cff340f..17f40d5 100644 --- a/Documentation/reactive.ru.md +++ b/Documentation/reactive.ru.md @@ -1,38 +1,5 @@ # Реактивное программирование -## Расширение Apexy для работы с RxSwift - -Если вы хотите использовать Apexy с RxSwift добавьте `Apexy/RxSwift` в Podfile. - -`pod 'Apexy/RxSwift'` - -Как использовать на примере `BookService` (смотри Example проект). - -```swift -final class BookService { - ... - func fetchBooks() -> Single<[Book]> { - let endpoint = BookListEndpoint() - return apiClient.request(endpoint) - } - ... -} -``` - -```swift -bookService.fetchBooks() - .do(onDispose: { [weak self] in - self?.activityView.isHidden = true - }) - .subscribe(onSuccess: { [weak self] books in - self?.activityView.isHidden = true - self?.show(books: books) - }, onFailure: { [weak self] error in - self?.activityView.isHidden = true - self?.resultLabel.text = error.localizedDescription - }).disposed(by: bag) -``` - ## Combine Apexy поддерживает Combine. diff --git a/Package.resolved b/Package.resolved index 6143a4d..dfc45eb 100644 --- a/Package.resolved +++ b/Package.resolved @@ -9,15 +9,6 @@ "revision": "becd9a729a37bdbef5bc39dc3c702b99f9e3d046", "version": "5.2.2" } - }, - { - "package": "RxSwift", - "repositoryURL": "https://github.com/ReactiveX/RxSwift.git", - "state": { - "branch": null, - "revision": "7e01c05f25c025143073eaa3be3532f9375c614b", - "version": "6.1.0" - } } ] }, diff --git a/Package.swift b/Package.swift index f2aa7e0..6528028 100644 --- a/Package.swift +++ b/Package.swift @@ -14,16 +14,13 @@ let package = Package( products: [ .library(name: "Apexy", targets: ["ApexyURLSession"]), .library(name: "ApexyAlamofire", targets: ["ApexyAlamofire"]), - .library(name: "ApexyRxSwift", targets: ["ApexyRxSwift"]), .library(name: "ApexyLoader", targets: ["ApexyLoader"]) ], dependencies: [ - .package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.2.0")), - .package(url: "https://github.com/ReactiveX/RxSwift.git", from: "6.0.0") + .package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.2.0")) ], targets: [ .target(name: "ApexyLoader", dependencies: ["Apexy"]), - .target(name: "ApexyRxSwift", dependencies: ["Apexy", "RxSwift"]), .target(name: "ApexyAlamofire", dependencies: ["Apexy", "Alamofire"]), .target(name: "ApexyURLSession", dependencies: ["Apexy"]), .target(name: "Apexy"), diff --git a/README.md b/README.md index 20bc3c5..cfc78c0 100644 --- a/README.md +++ b/README.md @@ -24,13 +24,7 @@ If you want to use Apexy with Alamofire: `pod 'Apexy'` -If you want to use Apexy with Alamofire and RxSwift: - -`pod 'Apexy'` - -`pod 'Apexy/RxSwift'` - -If you want to use Apexy without Alamofire and RxSwift: +If you want to use Apexy without Alamofire: `pod 'Apexy/URLSession'` @@ -44,14 +38,12 @@ If you have Xcode project, open it and select **File → Swift Packages → Add `https://github.com/RedMadRobot/apexy-ios` -There are 3 package products: Apexy, ApexyAlamofire, ApexyRxSwift. +There are 3 package products: Apexy, ApexyAlamofire, ApexyLoader. Apexy — Uses URLSession under the hood ApexyAlamofire — Uses Alamofire under the hood -If you want to use Apexy with RxSwift add ApexyRxSwift package product. - ApexyLoader — add-on for Apexy to store fetched data in memory and observe loading state. See the documentation for details [ApexyLoader](Documentation/loader.md): If you have your own Swift package, add Apexy as a dependency to the dependencies value of your Package.swift. @@ -114,7 +106,7 @@ client.request(endpoint) { (result: Result) `Client` - an object with only one method for executing `Endpoint`. - It's easy to mock, because it has only one method. - It's easy to send several `Endpoint`. -- Easily wraps into decorators or adapters. For example, you can wrap in `RxSwift` or `Combine` and you don't have to make wrappers for each request. +- Easily wraps into decorators or adapters. For example, you can wrap in `Combine` and you don't have to make wrappers for each request. The separation into `Client` and `Endpoint` allows you to separate the asynchronous code in `Client` from the synchronous code in `Endpoint`. Thus, the side effects are isolated in `Client`, and the pure functions in the non-mutable `Endpoint`. diff --git a/README.ru.md b/README.ru.md index 528d54b..19a50c0 100644 --- a/README.ru.md +++ b/README.ru.md @@ -24,13 +24,7 @@ `pod 'Apexy'` -Если вы хотите использовать Apexy с Alamofire и RxSwift: - -`pod 'Apexy'` - -`pod 'Apexy/RxSwift'` - -Если вы хотите использовать Apexy без Alamofire и RxSwift: +Если вы хотите использовать Apexy без Alamofire: `pod 'Apexy/URLSession'` @@ -45,14 +39,12 @@ `https://github.com/RedMadRobot/apexy-ios` -Будут достуны 4 продукта: Apexy, ApexyAlamofire, ApexyRxSwift, ApexyLoader. +Будут достуны 3 продукта: Apexy, ApexyAlamofire, ApexyLoader. Apexy — Под капотом использует URLSession ApexyAlamofire — Под капотом использует Alamofire -Если хотите использовать Apexy с RxSwift, то дополнительно подключайте пакет ApexyRxSwift. - ApexyLoader — дополнение для Apexy, которое позволяет хранить загруженные данные в памяти и следить за состоянием загрузки. Подробности смотрите в документации [ApexyLoader](Documentation/loader_ru.md): Если у вас есть Swift пакет, добавьте Apexy как зависимость в свойство dependencies файла Package.swift. @@ -115,7 +107,7 @@ client.request(endpoint) { (result: Result) `Client` - объект с одним методом способный выполнить `Endpoint`. - Легко мокается, так как у него один метод. - Легко отправить через него несколько разных `Endpoint`. -- Легко оборачивается в декораторы или адаптеры. Например можно обернуть в `RxSwift` или `Combine` и вам не придется делать обертки для каждого запроса. +- Легко оборачивается в декораторы или адаптеры. Например можно обернуть в `Combine` и вам не придется делать обертки для каждого запроса. Разделение на `Client` и `Endpoint` позволяет разделить асинхронный код в `Client` от синхронного кода в `Endpoint`. Таким образом сайд эффекты изолированы в одном месте `Client`, а чистые функции в немутабельных `Endpoint`. diff --git a/Sources/ApexyRxSwift/Client+RxSwift.swift b/Sources/ApexyRxSwift/Client+RxSwift.swift deleted file mode 100644 index 27bd2a1..0000000 --- a/Sources/ApexyRxSwift/Client+RxSwift.swift +++ /dev/null @@ -1,12 +0,0 @@ -import Apexy -import RxSwift - -public extension Client { - - func request(_ endpoint: T) -> Single where T: Endpoint { - Single.create { single in - let progress = self.request(endpoint) { single($0) } - return Disposables.create(with: progress.cancel) - } - } -}