airbnb / airbnb/epoxy

Better Kotlin support: LayoutContainer, synthetics

Open
#653 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
8.6k
Forks
734
PR merge metrics
No merged PRs in 30d

Description

Current documentation says that custom kotlin models are not officially supported.

I'm wondering if `EpoxyModel` augmented with `LayoutContainer` will let to skip the holder completely (https://kotlinlang.org/docs/tutorials/android-plugin.html#layoutcontainer-support). For some reason, at the moment it doesn't. Here is my attempt to make it work: https://github.com/Ghedeon/Trendroid/blob/master/app/src/main/java/com/ghedeon/trendroid/ui/trending/RepoItem.kt

As you can see, I had to disable the caching (`@ContainerOptions(cache = NO_CACHE)`) because my items were not rendered properly. And without cache, it's just a regular `findViewById`. The concise syntax is pretty neat tho...

Some possible (?) options with `Synthetics + EpoxyModel`:

1. `LayoutContainer` with no cache. Cleaner version of `EpoxyModel + findViewById` (slow).
2. `LayoutContainer` + Holder. Cleaner version of `EpoxyModel + KotlinEpoxyHolder` (better)
3. `LayoutContainer` with cache enabled. Supposedly solves all the above without the need of `Holder`.

Contributor guide

Open the contributing guide

Research direction

Start by reading the current documentation on custom Kotlin models and the linked RepoItem.kt example, then compare the three proposed LayoutContainer and synthetics options. Reproduce the rendering behavior with caching enabled and disabled; done requires a decided support approach with its expected behavior documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.