Swiftpack.co - liltimtim/porkchop-ios as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by liltimtim.
liltimtim/porkchop-ios v0.0.13
Combine based wrapper around URLSession
⭐️ 0
🕓 1 year ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/liltimtim/porkchop-ios.git", from: "v0.0.13")

Build Status

Swift

PorkChop

Combine based wrapper around URLSession

Supported Platforms

iOS 13+

MacOS 10.15+


Example Usage

There are three parts to using the library

Step 1 - Instantiate the library

    private var networking: PRKChopNetworking = .init()

Step 2 - Create a URLRequest

Create a URLRequest using the provided createRequest method.

    let request = networking.createRequest(url: URL(string: "https://your_url.com", httpMethod: <method>, body: PRKChopEmptyBody())

Step 3 - Pass the request

        let request = networking.createRequest(url: URL(string: "https://your_url.com", httpMethod: <method>, body: PRKChopEmptyBody())
        networkProvider
            .make(for: request)
            

Note that .make is an async function type that can throw. This method returns a Data object type and doesn't assume how you want to transform your data.

You can chain the response with .tryTransform(type: <type>) to be used with Decodable type of objects or structs.

GitHub

link
Stars: 0
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics