Does Circuit supports dynamic feature navigation? #698
-
Does Circuit support dynamic feature navigation? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
We haven't tried anything with it as we don't use it at slack, but it seems doable? We wouldn't use a fragment vs just using the install monitor ourselves and then calling navigate from there. The main technical hurdle I think would be getting the downloaded screens into your local circuirconfig, or you could build a custom factory that knows how to speak to downloaded ones |
Beta Was this translation helpful? Give feedback.
-
If we use this library for dynamic feature modules: https://github.com/cashapp/better-dynamic-features Then it would install/uninstall dynamic feature modules and it could look like this: // Code in :app
// Assume our "CircuitFeature" needs to contribute presenters/factories
public interface CircuitFeature : DynamicApi {
public fun presenterFactories(): Set<Presenter.Factory>
public fun viewFactories(): Set<Ui.Factory>
}
// MainActivity.kt
setContent {
val installHelper = rememberSplitInstallHelper()
val features by remember {
// as modules are installed they will be emitted as part of this flow.
installHelper.splitInstallManager.dynamicImplementations<CircuitFeature>()
}.collectAsState(initial = emptyList())
val isSplitInstalling by installHelper.isInstalling.collectAsState(initial = false)
val allPresenterFactories: List<Presenter.Factory> =
features.flatMap { it.presenterFactories() }
val allViewFactories: List<Ui.Factory> = features.flatMap { it.viewFactories() }
val circuit = Circuit.Builder()
.apply {
for (factory in allPresenterFactories) {
addPresenterFactory(factory)
}
for (factory in allViewFactories) {
addUiFactory(factory)
}
}
.build()
val backStack = rememberSaveableBackStack(LoginScreen)
val navigator = rememberCircuitNavigator(backStack)
CircuitCompositionLocals(circuit) {
NavigableCircuitContent(navigator, backStack)
}
} The biggest obstacle I see is how do we do dependency injection for this scheme? I don't want to lose all the nice things Edit: Oh wait, would that land on the LoginScreen every time you installed a DFM? hmmmm... I think |
Beta Was this translation helpful? Give feedback.
We haven't tried anything with it as we don't use it at slack, but it seems doable? We wouldn't use a fragment vs just using the install monitor ourselves and then calling navigate from there. The main technical hurdle I think would be getting the downloaded screens into your local circuirconfig, or you could build a custom factory that knows how to speak to downloaded ones