Skip to content

Testable network layer seamlessly integrating Combine Framework, and Async/Await using Swift Package

Notifications You must be signed in to change notification settings

rushisangani/NetworkKit

Repository files navigation

NetworkKit

iOS app's connectivity with NetworkKit – a simple yet powerful network layer seamlessly integrating Combine Framework, Async/Await, and Unit Tests.

GitHub Repos

Checkout this sample project SwiftMVVMDemo.

Examples

public protocol NetworkHandler {
    func fetch<T: Decodable>(request: Request) async throws -> T
    func fetch<T: Decodable>(request: Request) -> AnyPublisher<T, RequestError>
}
import NetworkKit

class PostService: PostRetrievalService {
    let networkManager: NetworkHandler
    
    init(networkManager: NetworkHandler = NetworkManager()) {
        self.networkManager = networkManager
    }
    
    func getPosts() async throws -> [Post] {
        try await networkManager.fetch(request: PostRequest.getPosts)
    }
}

Installation

Add NetworkKit to your project using Swift Package Manager - https://github.com/rushisangani/NetworkKit

Contributions

Feel free to submit issues or pull requests to enhance the functionality of NetworkKit.

Connect with Me

Connect with me on LinkedIn or follow me on Medium.

About

Testable network layer seamlessly integrating Combine Framework, and Async/Await using Swift Package

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages