What are some strategies for dealing with Kotlin and Android Lifecycles?
In this screencast, cast you'll learn how Android Lifecycles appear to inhibit some core behaviors of Kotlin. For very good reasons Kotlin favors:
- Initialization of properties at the point where they are declared
- That we should try to avoid using nullable variables wherever possible
- That we should strive for immutability wherever possible.
Adhering to these principles appears to be difficult when we are operating within an Android lifecycle, such as an Activity, where often we cannot initialize properties until onCreate() because the Activity is not valid before that point. During this video, we’ll look at some strategies for overcoming these difficulties.
Lateinit Modifier Documentation
Lazy Delegate Documentation
Kotlin Programming by Big Nerd Ranch