Skip to content

Commit

Permalink
Drop RxSwift support (#35)
Browse files Browse the repository at this point in the history
* Drop RxSwift support

* Update README.md

Co-authored-by: Anton Glezman <a.glezman@redmadrobot.com>

* Убрал упоминания RxSwift из README.ru.md

Co-authored-by: Anton Glezman <a.glezman@redmadrobot.com>
  • Loading branch information
subdan and modestman committed Jan 20, 2022
1 parent 6afcc21 commit 4559307
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 119 deletions.
6 changes: 0 additions & 6 deletions Apexy.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
33 changes: 0 additions & 33 deletions Documentation/reactive.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
33 changes: 0 additions & 33 deletions Documentation/reactive.ru.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
9 changes: 0 additions & 9 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
]
},
Expand Down
5 changes: 1 addition & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
14 changes: 3 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'`

Expand All @@ -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.
Expand Down Expand Up @@ -114,7 +106,7 @@ client.request(endpoint) { (result: Result<Book, Error>)
`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`.

Expand Down
14 changes: 3 additions & 11 deletions README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@

`pod 'Apexy'`

Если вы хотите использовать Apexy с Alamofire и RxSwift:

`pod 'Apexy'`

`pod 'Apexy/RxSwift'`

Если вы хотите использовать Apexy без Alamofire и RxSwift:
Если вы хотите использовать Apexy без Alamofire:

`pod 'Apexy/URLSession'`

Expand All @@ -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.
Expand Down Expand Up @@ -115,7 +107,7 @@ client.request(endpoint) { (result: Result<Book, Error>)
`Client` - объект с одним методом способный выполнить `Endpoint`.
- Легко мокается, так как у него один метод.
- Легко отправить через него несколько разных `Endpoint`.
- Легко оборачивается в декораторы или адаптеры. Например можно обернуть в `RxSwift` или `Combine` и вам не придется делать обертки для каждого запроса.
- Легко оборачивается в декораторы или адаптеры. Например можно обернуть в `Combine` и вам не придется делать обертки для каждого запроса.

Разделение на `Client` и `Endpoint` позволяет разделить асинхронный код в `Client` от синхронного кода в `Endpoint`. Таким образом сайд эффекты изолированы в одном месте `Client`, а чистые функции в немутабельных `Endpoint`.

Expand Down
12 changes: 0 additions & 12 deletions Sources/ApexyRxSwift/Client+RxSwift.swift

This file was deleted.

0 comments on commit 4559307

Please sign in to comment.