I wanna implement such an interface for ios’ UIViewController. I saw a lot of solutions with UIViewControllers written in Kotlin but in such cases I get an error
__attribute__((unavailable("Kotlin subclass of Objective-C class can't be imported"))) __attribute__((swift_name("SignInViewController"))) @interface SharedSignInViewController : NSObject @end;
My interface is
package com.example.familytreekmm.shared.base
import com.atitto.mvi_kmm.base.BaseActor
import com.atitto.mvi_kmm.base.BaseModelIntent
import com.atitto.mvi_kmm.base.BasePartialChange
import com.atitto.mvi_kmm.base.BaseViewIntent
import com.atitto.mvi_kmm.base.BaseViewState
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launchinterface BaseScreen<VI : BaseViewIntent,
SI : BaseModelIntent, S : BaseViewState,
PC : BasePartialChange<S>> {val actor: BaseActor<VI, SI, S, PC> val coroutineScope: CoroutineScope fun viewAttached() { val actorNotNull = actor ?: return actorNotNull.onCreate() coroutineScope.launch { actorNotNull.singleEvent .onEach { handleSingleEvent(it) } .catch { } .collect() } coroutineScope.launch { actorNotNull.viewState ?.onEach { render(it) } ?.catch { } ?.collect() } coroutineScope.launch { actorNotNull.progressVisible .onEach(::handleProgress) .collect() } coroutineScope.launch { actorNotNull.errorFlow .filterNotNull() .onEach(::handleError) .collect() } intents() ?.onEach { actorNotNull.processIntent(it) } ?.launchIn(coroutineScope) } fun viewDetached() { coroutineScope.cancel() } fun handleError(error: String) fun handleProgress(isProgressFlowing: Boolean) fun intents(): Flow<VI>? = null fun handleSingleEvent(event: SI) {} fun render(state: S) {}
}