79325132

Date: 2025-01-02 22:50:13
Score: 0.5
Natty:
Report link

First of all, your activity also shouldn't interact with UseCase. Any business logic should pass through the ViewModel.

For now, let's find a solution to your question:

You can pass an activity as a param of your fun. In this case you won't keep reference anywhere.

Another way is to pass lambda as a param of fun and just invoke this lambda in the ViewModel, Usecase whatever. In this case, your activity reference will be only in activity class. Sometimes it looks not very elegant but at least you keep your UI and domain layers clear. And this is the only one approach for KMP projects.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: Eugene Troyanskii