🧊
compose bloc
  • Overview
  • Setup
  • Differences from adrielcafe/voyager
  • Navigator documentation
    • Navigator Overview
      • Screen
      • ScreenModel
      • Navigator
  • Router and path-based navigation
  • Bloc documentation
    • Bloc and Cubit Overview
      • Cubit
      • Bloc
    • Blocs and Compose Overview
      • BlocProvider
      • MultiBlocProvider
      • BlocBuilder
      • BlocSelector
      • BlocListener
      • BlocConsumer
      • SelectorFor
Powered by GitBook
On this page

Was this helpful?

Differences from adrielcafe/voyager

PreviousSetupNextNavigator Overview

Last updated 2 years ago

Was this helpful?

  • The original voyager library does not support Compose Web

  • The original voyager library does not support path-based navigation.

  • voyager-androidx now work differently: all lifecycle handling hooks from the original code have been removed (AndroidScreenLifecycleOwner is not used anymore). This is because it caused many issues: see for example . But this does not mean that android lifecycle events are ignored. When an activity is destroyed then all associated ScreenModels and Blocs are automatically disposed and the associated flows cancelled

  • Also flows associated to blocs of an Activity are automatically paused when the Activity is paused

  • Now Screen lifecycle is handled in the following way: A Screen (and associated screen model and blocs) is disposed in the following cases

    • When the Screen is popped from the navigator stack

    • When the parent Activity where the Screen composable was started is destroyed

    In order to all this to work, now is required to declare the top level navigator in an activity with RootNavigator:

class MainScreen: Screen {
    @Composable
        override fun Content() {
            //... main screen implementation here
        }
}

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            //*IMPORTANT* need to use RootNavigator to initialize root navigator for activity, not as in original voyager
            RootNavigator(MainScreen())
        }
    }
}
issue 62