You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to create an optional bean, which should only be defined if other beans exists, or, if other bean conforms to certain condition (like it's method fun isAvailable(): Boolean returns true).
I know in theory I could make if (myCondition) { single }, but for that to work my condition has to evaluate at the moment of module evaluation. But at that time beans are not available and you cant do get() inside of your module definition. This condition evaluation should happen on a bean resolution instead.
Is this even possible with Koin? Maybe it's worth a feature request?
One of the usecases is optional beans depending on availability of certain features in your android phone. Imagine phone without simcard slot, it wont have a telephony features, thus all the related beans should not exist and be either stubbed or optional.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I want to create an optional bean, which should only be defined if other beans exists, or, if other bean conforms to certain condition (like it's method fun isAvailable(): Boolean returns true).
I know in theory I could make if (myCondition) { single }, but for that to work my condition has to evaluate at the moment of module evaluation. But at that time beans are not available and you cant do get() inside of your module definition. This condition evaluation should happen on a bean resolution instead.
Is this even possible with Koin? Maybe it's worth a feature request?
One of the usecases is optional beans depending on availability of certain features in your android phone. Imagine phone without simcard slot, it wont have a telephony features, thus all the related beans should not exist and be either stubbed or optional.
Beta Was this translation helpful? Give feedback.
All reactions