Swiftpack.co - joreilly/PeopleInSpacePackage as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by joreilly.
joreilly/PeopleInSpacePackage 1.4.0
Swift Package for https://github.com/joreilly/PeopleInSpace.
⭐️ 5
🕓 1 year ago
iOS macOS
.package(url: "https://github.com/joreilly/PeopleInSpacePackage.git", from: "1.4.0")

PeopleInSpacePackage

Swift Package for https://github.com/joreilly/PeopleInSpace. Note that this uses https://github.com/rickclephas/KMP-NativeCoroutines library and right now Swift Package for this needs to be also manually added (looking at ways to do this automatically).

Example SwiftUI code

import SwiftUI
import common
import KMPNativeCoroutinesAsync


struct ContentView: View {
    let repository = PeopleInSpaceRepository()
    @State var people = [Assignment](https://raw.github.com/joreilly/PeopleInSpacePackage/main/)

    
    var body: some View {
        List(people, id: \.name) { person in
            Text(person.name)
        }
        .task {
            await startObservingPeopleUpdates()
        }
    }

    func startObservingPeopleUpdates() async {
        do {
            let stream = asyncStream(for: repository.fetchPeopleAsFlowNative())
            for try await data in stream {
                self.people = data
            }
        } catch {
            print("Failed with error: \(error)")
        }
    }
}    

Note that it's also necessary to initialise Koin (like following for example)

import SwiftUI
import ConfettiKit

@main
struct YourApp: App {
    init() {
        KoinKt.doInitKoin()
    }
    
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

GitHub

link
Stars: 5
Last commit: 25 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

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