With Kotlin's property delegates, you can easily customize the behavior of a property. In this video, we'll learn how Kotlin's delegated properties work, by turning Android's SharedPreferences into a delegate.
To see this code working within the context of a full Android app, see the companion code:
https://github.com/djleeds/video-shared-preferences-delegates
✨ New to Kotlin? Start here: https://typealias.com/start/
... or pick up the new Leanpub Edition! https://book.typealias.com/
🚀 I just launched a new email newsletter!
Sign up here: https://newsletter.typealias.com/
More fun with extension operator functions!
https://www.youtube.com/watch?v=Q0RYVV9rZBI
More about extension functions:
https://typealias.com/start/kotlin-receivers-and-extensions/
More about reified type parameters:
https://typealias.com/guides/getting-real-with-reified-type-parameters/
Chapters:
00:00 Introduction
00:45 Introduction to Property Delegates
03:18 Simple SharedPreferences Delegation
07:24 Exploring Improvements
10:00 Advanced SharedPreferences Delegation
20:47 Conclusion
If you've got ideas on how we could improve the code in this video, let me know in the comments!