<@U0BRK9HC5> commented on <@U0Z3X3AN6>’s file <htt...
# android
u
@gildor commented on @rudolf.hladik’s file https://kotlinlang.slack.com/files/U0Z3X3AN6/F3DUG9YRF/hey__im_trying_to_implement_RxBus_but_it_doesnt_work__which_is_strange__because_the_java_eqiuvalent_works_just_fine.kt: Just got why your code doesn’t work. This is because of wrong implementation of singleton, each call of
instanceOf()
overrides instance value. Use nullable instance and check for null or use lateinit and isInitialized before set instance to the field. But, actually, just remove companion object and use
object MyRxBus
instead to get correct implementation of singleton with better syntax (no instanceOf calls)