int for example the `ApiManager.INSTANCE.doSomethi...
# android
m
int for example the
ApiManager.INSTANCE.doSomething()
, can we override the INSTANCE getter function?
g
What is your use case for this?
m
I want to check if a variable is initialized inside that class
s
::something.isInitialized
g
You cannot override
object
instance directly. Check it in doSomething() Or alternatively expose this object using own property that would check a variable
But in general this approach smells, same as most of usages of Singleton pattern with initialization
m
yes but Object is a
Singleton
which may depend on something that is not there yet
g
Yes, I got your case, and saying that you can do check using special getter function, just abstract actual object, but Singleton with initialization sounds as antipattern and you probably should use standard class with constructor instead
👍 1
k
sounds like a job for DI or service locator
👍 4