M
M
Maxim Siomin2021-04-30 17:11:59
Android
Maxim Siomin, 2021-04-30 17:11:59

When should you use an application class?

Here I have ViewModel() and Application(). The UI has onClickListener, it contains a function call that saves key-value data. The function that saves key-value data ( fun saveData(data: Boolean) { }) should be in the ViewModel or in the Application?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2021-04-30
@MaxSiominDev

Very rarely is it needed. For example, a DI root should grow from it. Also there can be all sorts of specific things, such as initializing the multidex, initializing the crash logging libraries, and loading native libraries.
The saveData function should definitely not be in it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question