This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| createPublisher(wrapper: loadUserUseCase.loadUser(username: "noone special")) | |
| .sink( | |
| receiveCompletion: { completion in | |
| print("Completion: \(completion)") | |
| }, | |
| receiveValue: { user in | |
| print("Hello from the Kotlin side \(user?.name)") | |
| } | |
| ) | |
| .store(in: &cancellables) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func createPublisher<T>( | |
| wrapper: KoruSuspendWrapper<T> | |
| ) -> AnyPublisher<T?, Error> { | |
| var job: Kotlinx_coroutines_coreJob? = nil | |
| return Deferred { | |
| Future<T?, Error> { promise in | |
| job = wrapper.subscribe( | |
| onSuccess: { item in promise(.success(item)) }, | |
| onThrow: { error in promise(.failure(SharedError(error))) } | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let loadUserUseCase = sharedComponent.provideLoadUserUseCase() | |
| loadUserUseCase.loadUser(username: "nobody special").subscribe( | |
| onSuccess: { user in print(user?.description()) }, | |
| onThrow: { error in print(error.description()) } | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @UIApplicationMain | |
| class AppDelegate: UIResponder, UIApplicationDelegate { | |
| let sharedComponent = IosComponent() | |
| func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
| IosComponentKt.doInitIosDependencies() | |
| return true | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun initIosDependencies() = startKoin { | |
| modules(commonModule, iosModule) | |
| } | |
| private val iosModule = module { | |
| factory { LoadUserUseCaseIos(get()) } | |
| factory { SaveUserUseCaseIos(get()) } | |
| factory { ObserveUsersUseCaseIos(get()) } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val commonModule = module { | |
| single { UserService() } | |
| factory { LoadUserUseCase(get()) } | |
| factory { SaveUserUseCase(get()) } | |
| factory { ObserveUsersUseCase(get()) } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @ExportedScopeProvider | |
| class MainScopeProvider : ScopeProvider { | |
| override val scope : CoroutineScope = MainScope() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class SaveUserUseCaseIos( | |
| private val wrapped: SaveUserUseCase | |
| ) { | |
| public fun saveUser(user: User): SuspendWrapper<Unit> = | |
| SuspendWrapper(exportedScopeProvider_mainScopeProvider) { wrapped.saveUser(user) } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| plugins { | |
| kotlin("multiplatform") | |
| id("com.android.library") | |
| kotlin("kapt") | |
| } | |
| kotlin { | |
| //... | |
| sourceSets { | |