- Notifications
You must be signed in to change notification settings - Fork121
Home
John O'Reilly edited this pageOct 21, 2022 ·3 revisions
The shared code is published as a Swift Package (using theKMMBridge tool). To use just go to File/Add Package in XCode and enterhttps://github.com/joreilly/Confetti (as shown below)

Note that this useshttps://github.com/rickclephas/KMP-NativeCoroutines library and right now Swift Package for this needs to be also manually added in XCode.
import SwiftUIimport ConfettiKitimport KMPNativeCoroutinesAsyncstructContentView:View{letrepository=ConfettiRepository()@Statevarsessions:[SessionDetails]=[]varbody:someView{List(sessions, id: \.id){ sessioninVStack(alignment:.leading){Text(session.title).bold()Text(session.room?.name??"")}}.task{awaitobserveSessions()}}func observeSessions()async{ repository.setConference(conference:"droidconlondon2022")do{letstream=asyncStream(for: repository.sessionsNative)fortryawaitdatain stream{self.sessions= data}}catch{print("Failed with error:\(error)")}}}
Note that it's also necessary to initialise Koin (like following for example)
import SwiftUIimport ConfettiKit@mainstructYourApp:App{init(){KoinKt.doInitKoin()}varbody:someScene{WindowGroup{ContentView()}}}