Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support onBind/onUnbind listeners on generated models #140

Merged
merged 2 commits into from
Mar 3, 2017

Conversation

elihart
Copy link
Contributor

@elihart elihart commented Mar 3, 2017

Generated models now include onBind and onUnbind builder style method that takes a callback listener. When the model hits these lifecycle events the listener will be called with the model and view that was bound.

This looks like

new LoaderModel_()
       .onBind((model, view) -> loadMore())
       .addTo(this);

The goal is to avoid having one adapter method for handling onModelBound, and instead keeping the logic where the model is created.

This involved quite a bit change to the processor to generate the correct interface, store the listener fields, update hashCode/equals, etc. Also had to update all the tests.

Since I was updating all the tests and figuring out a good way to do this, I realized a better way to do the model click listener handling as well without storing the viewholder and bound object on the model. This seems cleaner and safer.

@elihart
Copy link
Contributor Author

elihart commented Mar 3, 2017

@gpeal @ngsilverman

@elihart elihart force-pushed the eli/bind_callback branch from 8bf0996 to 7a4b27a Compare March 3, 2017 06:44
@ngsilverman
Copy link
Contributor

Love it. 👍

This was referenced Mar 3, 2017
@elihart elihart merged commit 98c2d4b into 2.0 Mar 3, 2017
@elihart elihart deleted the eli/bind_callback branch March 3, 2017 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants