Advantage of Paris when used with Epoxy and MvRx
qbait opened this issue · comments
I use MvRx
and Epoxy
. I'm looking at Paris
lib, but I'm not sure if I'm not overengineering by using it.
For my Epoxy view, I could define enum with styles
enum class Style {
RED, GREEN, BLUE
}
And define the function that will programmatically style my views.
@ModelProp
fun style(style: Style) {
when(style) {
Style.RED -> {}
Style.GREEN -> {}
Style.BLUE -> {}
}
}
What's the advantage of using Paris
over having a simple style function?
@qbait While you can achieve the same thing using Epoxy, I think the following Paris features will make the code safer and more concise:
- Same attributes assertion to make sure recycling always works as expected (https://github.com/airbnb/paris/wiki/View-Recycling).
- Style inheritance and combinations (https://github.com/airbnb/paris/wiki/Building-and-Applying-Styles#combining-styles).
- Subview support (https://github.com/airbnb/paris/wiki/Custom-Views#styling-subviews).
Results will vary depending on how complex your styles and custom views are. At Airbnb we also use the style linking feature (https://github.com/airbnb/paris/wiki/Custom-Views#linking-styles-to-custom-views) for testing.