google-developer-training / android-basics-kotlin-cupcake-app

Apache License 2.0
103 stars 163 forks source link

Transformations.map #91

Closed ParkerS6 closed 10 months ago

ParkerS6 commented 1 year ago

(https://developer.android.com/codelabs/basic-android-kotlin-training-shared-viewmodel?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-kotlin-unit-3-pathway-4%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-training-shared-viewmodel#7)

Step 8 Format Price with LiveData transformation

When using lifecycle implementation version 2.6.1 the transformations function can no longer be used and you must instead use example.map or example.switchMap rather than Transformations.map

rishabhagg7 commented 1 year ago

Which version of the androidx.lifecycle library are you using? If it's 2.6.0 or newer then you should replace Transformations.map(_price) { } with _price.map { }. See the changelog for version 2.6.0.