Răzvan Roșu
08/04/2020, 9:43 AM@Module
public interface LoginCommandModule { // part of the root component
...
@BindsOptionalOf
Account optionalAccount();
}
@Subcomponent(modules = ...)
@PerSession
public interface UserCommandsRouter {
CommandRouter router();
@Subcomponent.Factory
interface Factory {
UserCommandsRouter create(@BindsInstance Database.Account account);
}
@Module(subcomponents = UserCommandsRouter.class)
interface InstallationModule { // Included in the RootComponent
}
}
What would be the usages of the @BindsOptionalOf annotation besides checking if the subcomponent has already been initialized? And, if there are multiple subcomponents, which Account from which subcomponent would be selected in order to be used by the root component?