Thanks to visit codestin.com
Credit goes to github.com

Skip to content

yusasarisoy/CoreSession

Repository files navigation

CoreSession Logo

CoreSession

Minimal and modern network layer for Swift.


Installation

Add via Swift Package Manager:

https://github.com/yusasarisoy/CoreSession

Example

import CoreSession

// MARK: - ExampleRequest

enum ExampleRequest {
  case fetchExampleData(_ page: Int)
}

// MARK: - ExampleData

struct ExampleData: Decodable {
    let id: Int
    let name: String
}

// MARK: - RequestProtocol

extension ExampleRequest: RequestProtocol {
  typealias Response = ExampleData
  
  var path: String {
    "YOUR_PATH"
  }
  
  var urlParams: [String: String?] {
    switch self {
    case let .fetchExampleData(page):
      let params: [String: String?] = [
        "limit": String(page)
      ]
      return params
    }
  }
  
  var requestType: RequestType {
    .GET
  }
}

Concept

Endpoints describe what to request.
The session defines how it’s performed.
The decoder defines how it’s interpreted.


License

MIT

About

A high cohesion, low coupling Swift framework designed with async/await for concurrency.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages