Kotlin Parcelize Power Features

Words
113
Reading
1 min
Listen
Play
9y

聽You are going to delete lots of lines of code! Yes, it is not a clickbait!

How do you pass your model between activities?

  • Serializable?
  • EventBus / Otto聽?
  • Parcelable?

Serializable = Reflection! Run Forest Run!!! It is terrible for Android performance. Bus libraries like EventBus or Otto are easy to use and have good performance but after some time they cause too much complexity in your code.

Parcelable interface is great for Android performance but it has too much boilerplate.

Parcelize 馃槏

Kotlin added parcelable support in version 1.1.4.Android Extensions plugin now includes an automatic聽Parcelable聽implementation generator. Declare the serialized properties in a primary constructor and add a聽@Parcelize聽annotation, and聽writeToParcel()/createFromParcel()聽methods will be created automatically.

Source

Kotlin Parcelize Power Features | Ecency