How can i override activity lifecycle methods in a...
# compose-ios
s
How can i override activity lifecycle methods in a composable? i've a composable called "HomeScreen" now i want to have all activity lifecycle methods in it. Currently i've ios and android in commonMain.
d
in iOS where are no Activity. Is's analogue calls UIViewController. For Android you can read Android docs. You need to use Lifecycle callbacks. https://developer.android.com/guide/components/activities/activity-lifecycle For iOS you can use this approach:
Copy code
ComposeUIViewController(
    configure = {
        delegate = object: ComposeUIViewControllerDelegate {
            override fun viewDidLoad() {
                // Some reaction
            }
            override fun viewWillAppear(animated: Boolean) {
                // Some reaction
            }
            override fun viewDidAppear(animated: Boolean) {
                // Some reaction
            }
            override fun viewWillDisappear(animated: Boolean) {
                // Some reaction
            }
            override fun viewDidDisappear(animated: Boolean) {
                // Some reaction
            }
        }
    }
) {
    Text("Here your Compose code")
}