https://github.com/touchlab/swiftcoroutines
https://github.com/touchlab/swiftcoroutines
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/touchlab/swiftcoroutines
- Owner: touchlab
- Created: 2020-06-15T16:18:56.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-05-18T20:11:53.000Z (almost 4 years ago)
- Last Synced: 2025-04-05T13:05:01.717Z (12 months ago)
- Language: Swift
- Size: 449 KB
- Stars: 59
- Watchers: 16
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Swift/Coroutines interop
This is the code associated
with [this updated blog post](https://dev.to/touchlab/kotlin-coroutines-and-swift-revisited-j5h) on Coroutines and
Swift interop. If you can here from
the [first version](https://dev.to/touchlab/working-with-kotlin-coroutines-and-rxswift-24fa), you can find the original
sample code on the [v1 branch](https://github.com/touchlab/SwiftCoroutines/tree/v1)
The `shared` directory contains Kotlin code, including a `ThingRepository` in common and a wrapper `ThingRespositoryIos`
in the ios sources, which makes use of interop utilities in `SwiftCoroutines.kt`.
The Kotlin code is consumed by an Xcode project in the `ios` directory. In there, `RxSwiftWrappers.swift` defines the
RxSwift linkages to the coroutine wrappers in `SwiftCoroutines.kt`, and makes a demo call in `SceneDelegate.swift`.
Additionally, `CombineWrappers.swift` defines equivalent Combine functions, with a demo call in `SceneDelegate.swift`
as well as SwiftUI consumtion in `SwiftUIDemo.swift`. There are also unit tests in `RxSwiftWrappersTests.swift` and
`CombineWrappersTests` which, while not exhaustive, verify most of the workings of the interop code, including checking
multithreaded usage and cancellation.