# property-delegation

Published articles for property-delegation.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Property delegation

DevFeed: [Property delegation](<https://devfeed.tech/articles/property-delegation-39213.md>)

Original publisher: [Read original article](<https://kt.academy/article/ak-property-delegation>)

Published: 2023-03-20T00:15:00Z

Content type: tutorial

Language: en

Sources: [Kt. Academy](<https://devfeed.tech/sources/kt-academy.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [properties](<https://devfeed.tech/topics/properties.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Refactoring](<https://devfeed.tech/topics/refactoring.md>)

Tags: [behavior](<https://devfeed.tech/tags/behavior.md>), [function](<https://devfeed.tech/tags/function.md>), [implement](<https://devfeed.tech/tags/implement.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [patterns](<https://devfeed.tech/tags/patterns.md>), [property](<https://devfeed.tech/tags/property.md>), [property-delegation](<https://devfeed.tech/tags/property-delegation.md>), [workshop-learning-programming](<https://devfeed.tech/tags/workshop-learning-programming.md>)

### AI overview

This tutorial explains Kotlin property delegation, a feature for extracting reusable property patterns such as lazy, observable, binding, and dependency-injection behaviors. It describes how delegated getters and setters work and how to implement custom property delegates.

### Source excerpt

What is property delegation, how does it work, and how can we implement our custom property delegate.

## Kotlin property delegates for Datastore Preferences library

DevFeed: [Kotlin property delegates for Datastore Preferences library](<https://devfeed.tech/articles/kotlin-property-delegates-for-datastore-preferences-library-26020.md>)

Original publisher: [Read original article](<https://proandroiddev.com/kotlin-property-delegates-for-datastore-preferences-library-5d4e1cdb609b?source=rss-e93d234beac6------2>)

Author: Yahor Urbanovich

Published: 2021-08-23T15:40:08Z

Content type: tutorial

Language: en

Sources: [Stories by Yahor Urbanovich on Medium](<https://devfeed.tech/sources/stories-by-yahor-urbanovich-on-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Library](<https://devfeed.tech/topics/library.md>), [Coroutines](<https://devfeed.tech/topics/coroutines.md>), [kotlin-flow](<https://devfeed.tech/topics/kotlin-flow.md>), [migration](<https://devfeed.tech/topics/migration.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [delegates](<https://devfeed.tech/tags/delegates.md>), [delegation](<https://devfeed.tech/tags/delegation.md>), [deprecated](<https://devfeed.tech/tags/deprecated.md>), [flow](<https://devfeed.tech/tags/flow.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-flow](<https://devfeed.tech/tags/kotlin-flow.md>), [library](<https://devfeed.tech/tags/library.md>), [migration](<https://devfeed.tech/tags/migration.md>), [property-delegation](<https://devfeed.tech/tags/property-delegation.md>), [suspend-function](<https://devfeed.tech/tags/suspend-function.md>)

### AI overview

This tutorial explains migrating preference storage from SharedPreferences to AndroidX DataStore Preferences. It shows how Kotlin property delegation can encapsulate reading and writing values, and how Flow, coroutines, first(), and runBlocking can support single-value access despite DataStore's Flow-based API.

### Source excerpt

Kotlin delegated property for Datastore Preferences library Recently AndroidX Datastore 1.0 was released. The moment has come, it's time to migrate away from SharedPreferences. As for me, the key benefit is the built-in support of Kotlin Flow and Coroutines. Previously we had to write our own wrapper under SharedPreferences.OnSharedPreferenceChangeListener, emit changes into ConflatedBroadcastChannel and then convert it into Flow. https://medium.com/media/b5410ce9df08d9b73427a2138a6b0a8d/href Firstly, this approach produces a lot of intermediate variables. Secondly, ConflatedBroadcastChannel deprecated and should be replaced with StateFlow. In this case, DataStore comes out as the winner. The migrated to DataStore version looks clean and simple. https://medium.com/media/cce0d485e2af9941e677dc7973a54c6f/hrefRead/write single value using SharedPreferences Let's imagine, we need to store the current App theme as String. For this purpose, we need to initialize SharedPreferences, then make two functions to read and write these values. https://medium.com/media/3bc9760a22ebd1071e4dcb21eaf8d4ba/href Well, two functions it is not so bad, but we can try to merge this into single Property. https://medium.com/media/c3babbf2b6c55bb18172f66ddc825b06/href To make it fully clear and supportable we can use the Kotlin delegation feature. As we want to read and write simultaneously, ReadWriteProperty will suit our goal. https://medium.com/media/80f370a5a5735b911c75d3a0f1d22b21/href Please take a look at the final compact version, where all logic is encapsulated inside the delegate. https://medium.com/media/39b5311b04373b1f31d3030b8b083587/hrefDataStore Preferences and missing API During migration, it turned out that the library doesn't provide an API for reading a single property. DataStore proposes to use Flow for all cases. Developers are now required to read/write the value in the scope of a suspend function. https://medium.com/media/e7c4e45e239e11bc5082f3997e5280dd/href What was e

## Property delegation in Kotlin: Assign values in Android without having the context (KAD 15)

DevFeed: [Property delegation in Kotlin: Assign values in Android without having the context (KAD 15)](<https://devfeed.tech/articles/property-delegation-in-kotlin-assign-values-in-android-without-having-the-context-kad-15-27216.md>)

Original publisher: [Read original article](<https://antonioleiva.com/property-delegation-kotlin>)

Published: 2017-03-09T00:00:00Z

Content type: tutorial

Language: en

Sources: [Antonio Leiva](<https://devfeed.tech/sources/antonio-leiva.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Android](<https://devfeed.tech/topics/android.md>), [context](<https://devfeed.tech/topics/context.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [adapter](<https://devfeed.tech/tags/adapter.md>), [android](<https://devfeed.tech/tags/android.md>), [context](<https://devfeed.tech/tags/context.md>), [dagger](<https://devfeed.tech/tags/dagger.md>), [delegation](<https://devfeed.tech/tags/delegation.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [property-delegation](<https://devfeed.tech/tags/property-delegation.md>)

### AI overview

This tutorial explains Kotlin property delegation for Android development, including delaying property initialization when context is unavailable during object creation, lazily assigning a view, observing property changes in an adapter, and declaring a Dagger graph lazily.

### Source excerpt

Everything Android, Kotlin and other random topics

## Converting Plaid to Kotlin: Lessons learned (Part 1)

DevFeed: [Converting Plaid to Kotlin: Lessons learned (Part 1)](<https://devfeed.tech/articles/converting-plaid-to-kotlin-lessons-learned-part-1-27214.md>)

Original publisher: [Read original article](<https://antonioleiva.com/plaid-kotlin-1>)

Published: 2015-11-03T00:00:00Z

Content type: tutorial

Language: en

Sources: [Antonio Leiva](<https://devfeed.tech/sources/antonio-leiva.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Android](<https://devfeed.tech/topics/android.md>), [android-apps](<https://devfeed.tech/topics/android-apps.md>), [Code](<https://devfeed.tech/topics/code.md>), [properties](<https://devfeed.tech/topics/properties.md>), [context](<https://devfeed.tech/topics/context.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [code](<https://devfeed.tech/tags/code.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [properties](<https://devfeed.tech/tags/properties.md>), [property](<https://devfeed.tech/tags/property.md>), [property-delegation](<https://devfeed.tech/tags/property-delegation.md>)

### AI overview

This tutorial compares part of the Plaid Android app after rewriting HomeActivity in Kotlin. It discusses reduced boilerplate and Kotlin approaches to view binding, resource binding, property declarations, context-dependent initialization, and property delegation.

### Source excerpt

Everything Android, Kotlin and other random topics