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

Usage example for recycler #2

Closed
yschimke opened this issue Jan 8, 2018 · 1 comment
Closed

Usage example for recycler #2

yschimke opened this issue Jan 8, 2018 · 1 comment

Comments

@yschimke
Copy link

yschimke commented Jan 8, 2018

Currently using component instead

        component(c, RecyclerCollectionComponent::create) {
          section(
              ResultsListSection.create(SectionContext(c)).results(results).build())
              .disablePTR(true).flexGrow(1f)
        }

But ideal would be closer to

        recycler(RecyclerCollectionComponent::create) {
          section {
            results(results).build()).disablePTR(true).flexGrow(1f)
          }
        }
@vinc3m1
Copy link
Owner

vinc3m1 commented Jun 12, 2018

You just need to define a new extension function, basically exactly what you did with component except define it with a name somewhere:

@LithoMarker
fun recyclerCollectionComponent(c: ComponentContext,
                                init: RecyclerCollectionComponent.Builder.() -> Unit) =
    component(c, RecyclerCollectionComponent::create, init)

@LithoMarker
fun ChildHolder.recyclerCollectionComponent(c: ComponentContext,
                                            init: RecyclerCollectionComponent.Builder.() -> Unit) =
    component(c, RecyclerCollectionComponent::create, init)

Going to close this for now as I'll be updating and adding this function in a few minutes.

@vinc3m1 vinc3m1 closed this as completed Jun 12, 2018
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

No branches or pull requests

2 participants