trbnb / MvvmBase

Apache License 2.0
15 stars 7 forks source link

Events not working in fragments #12

Closed Tetr4 closed 5 years ago

Tetr4 commented 5 years ago

MvvmFragment::onEvent is not being called when the viewmodel sends an event via the event channel. When manually adding a listener to the channel it works, but only via a lambda or variable reference:

viewModel.eventChannel.addListener { Log.d(event, "$it" }

When passing the method directly it does not work:

viewModel.eventChannel.addListener(this::onEvent)

I think the bug may be in MvvmBindingFragment. viewModel.eventChannel.addListener(::onEvent) is called instead of viewModel.eventChannel.addListener(eventListener).

trbnb commented 5 years ago

That's exactly right. I've encountered this issue already and it will be fixed in the next release.

Tetr4 commented 5 years ago

Nice, thanks 😄

trbnb commented 5 years ago

It took a while, but it's fixed and released.