Skip to content

Commit

Permalink
fix: remove un-needed files + update outdated readme file
Browse files Browse the repository at this point in the history
Resolves: none.
  • Loading branch information
loay-ashraf committed Jan 27, 2024
1 parent afb4c5d commit cb9ea84
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 106 deletions.
Binary file removed Docs.docc/Resources/article-getting-started-#4.png
Binary file not shown.
Binary file removed Docs.docc/Resources/article-getting-started-#5.png
Binary file not shown.
Binary file not shown.
Binary file removed Docs.docc/Resources/article-getting-started-#7.png
Binary file not shown.
108 changes: 2 additions & 106 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,113 +9,9 @@
[![Twitter](https://img.shields.io/badge/Twitter-%40lashraf96-blue)](https://twitter.com/lashraf96)
[![LinkedIn](https://img.shields.io/badge/LinkedIn-loay--ashraf-blue)](https://linkedin.com/in/loay-ashraf)

RxNetworkKit is a lightweight FRP networking framework.
RxNetworkKit is a generic reactive networking framework that leverages the stability and reliability of both Apple's [URLSession](https://developer.apple.com/documentation/foundation/urlsession) and [RxSwift](https://github.com/ReactiveX/RxSwift).

Built on top of Apple's [URLSession](https://developer.apple.com/documentation/foundation/urlsession) and uses the well-known [RxSwift](https://github.com/ReactiveX/RxSwift) FRP library.

## Why RxNetworkKit?

RxNetworkKit fits nicely on your project if you use RxSwift and RxCocoa mainly in your project.

It makes use of RxSwift's traits at request level to acheive a high level of specialization for observed request sequence and expected output from it.

### Full of Goodies:

- includes download and upload capabillity with progress tracking all within the same observable sequence. cool, right?
- includes a request interceptor protocol that can be implemented for request adaptation and retry on failure.
- comes with a reachability class that you can observe from anywhere for reachability status.

## Practical Examples

### Simple API Call:

```
// Create `Session` instance.
let session = Session(configuration: .default)
// Create 'RESTClient' instance.
let restClient = RESTClient(session: session, requestInterceptor: self)
// Create `HTTPRequestRouter` instance.
let router = Router.default
// Make request observable sequence using request router.
let single: Single<Model> = restClient.request(router)
// Subscrible to sequence and observe events.
single
.observe(on: MainScheduler.instance)
.subscribe(onSuccess: {
print("Task Response: \($0)")
print("Task Completed!")
}, onFailure: {
print("Task Failure: \($0.localizedDescription)")
}, onDisposed: {
print("Subscription is disposed!")
})
// Dispose subscription by dispose bag.
.disposed(by: disposeBag)
```

### Download Request:

```
// Create `Session` instance.
let session = Session(configuration: .default)
// Create 'HTTPClient' instance.
let httpClient = HTTPClient(session: session, requestInterceptor: self)
// Create `HTTPDownloadRequestRouter` instance.
let router = DownloadRouter.default
// Make download request observable sequence using request router.
let downloadObservable: Observable<HTTPDownloadRequestEvent> = httpClient.download(router)
// Subscrible to sequence and observe events.
downloadObservable
.observe(on: MainScheduler.instance)
.subscribe(onNext: {
switch $0 {
case .progress(let progress):
print("Download Task Progress: \(progress.fractionCompleted*100)%")
case .completedWithData(let data):
print("Download Task Completed with data: \(data).")
default: break
}
}, onError: {
print("Download Task Failure: \($0.localizedDescription)")
}, onCompleted: {
print("Download Task Completed!")
})
// Dispose subscription by dispose bag.
.disposed(by: disposeBag)
```

### Upload Request:

```
// Create `Session` instance.
let session = Session(configuration: .default)
// Create 'HTTPClient' instance.
let httpClient = HTTPClient(session: session, requestInterceptor: self)
// Create `HTTPUploadRequestRouter` instance.
let router = UploadRouter.default
// Make 'HTTPUploadRequestFile' instance.
let fileData = Data()
guard let file = UploadFile(forKey: UUID().uuidString, withName: "testFile.txt", withData: fileData) else { return }
// Make upload request observable sequence using request router and upload file object.
let uploadObservable: Observable<HTTPUploadRequestEvent<UploadModel>> = httpClient.upload(router, file)
// Subscrible to sequence and observe events.
uploadObservable
.observe(on: MainScheduler.instance)
.subscribe(onNext: {
switch $0 {
case .progress(let progress):
print("Upload Task Progress: \(progress.fractionCompleted*100)%")
case .completed(let model):
print("Upload Task Completed with Response: \(model)")
}
}, onError: {
print("Upload Task Failure: \($0.localizedDescription)")
}, onCompleted: {
print("Upload Task Completed!")
})
// Dispose subscription by dispose bag.
.disposed(by: disposeBag)
```
To get started with the framework, please refer to the [developer documentation](https://loay-ashraf.github.io/RxNetworkKit/).

## Requirements

Expand Down

0 comments on commit cb9ea84

Please sign in to comment.