https://kotlinlang.org logo
#compose
Title
# compose
r

rsktash

01/19/2021, 7:38 AM
Hi. Anybody tried to make a mpp app with dynamic features with compose? I have two dynamic feature modules. The main module will be available by default. The other two modules will be installed on demand. How can I access on demand module composable functions from main module?
@Arkadii Ivanov
a

Arkadii Ivanov

01/19/2021, 11:53 AM
Hello @rsktash, unfortunately I never used dynamic features. 😞
r

rsktash

01/19/2021, 12:00 PM
@Arkadii Ivanov Thank you anyway. I think we can create Factory interface for each component in main module and Factory classes of them in dynamic modules and load via serviceloader.
a

Arkadii Ivanov

01/19/2021, 12:25 PM
Sounds like a plan to try 🙂
z

zalewski.se

03/31/2021, 9:13 AM
@rsktash Were you able to make it work? 🙂
r

rsktash

03/31/2021, 10:42 AM
@zalewski.se Yes
z

zalewski.se

03/31/2021, 10:43 AM
Do you have some example that you could share? I would love to take a look if possible
r

rsktash

03/31/2021, 10:52 AM
I am using decompose for routing / navigation and model I have common shared logic modules between android and desktop say: main(basic), moderator, admin And I have shared compose ui modules: main, moderator, admin And android dynamic modules moderator, admin which have dependency to ui and logic. I have a dynamic_module detector class FeatureChecker which checks for available modules and FeatureRenderer which call composable functions using reflection. These helper classes will be passed to the component tree context and will be used for checking features and loading ui
For desktop the helper classes simply return true for any feature check and renderer class calls composable functions directly. There is no such a dynamic feature implementation
z

zalewski.se

03/31/2021, 11:20 AM
I see! That’s really interesting, soon will dig into it by myself too
2 Views