airbnb / epoxy

Epoxy is an Android library for building complex screens in a RecyclerView
https://goo.gl/eIK82p
Apache License 2.0
8.46k stars 730 forks source link

Unable to refresh the listening callback #1328

Open TonyYu668 opened 1 year ago

TonyYu668 commented 1 year ago

eg: private fun buildHeader(state: HeaderState){

    headerViewModelBulder{ // headerViewModelBulder is generated by Expoxy
        btnClick{
             Log.d("get data:${state.name}")     
        }
    }

}

When the data changes, headerViewModelBulder() executes again, but the data retrieved from the log remains unchanged because the state object points to the previous address.

The reason is that the callback was not updated and was set for the first time。

Corresponding generated code logic:

if (((btnClick_Function0 == null) != (that.btnClick_Function0 == null))) {
object.seBtnClick(......); //Update callback again, but not executed here. }

I think the ability to repeatedly set callbacks should be supported

viroth-ty commented 1 year ago

Can you share your epoxy models?