RoomList: avoid to many recompositions

This commit is contained in:
ganfra 2022-10-30 13:48:06 +01:00
parent 485b38efad
commit fcf7e8d7f1
8 changed files with 88 additions and 41 deletions

View file

@ -0,0 +1,22 @@
package io.element.android.x.core.data
import android.util.Log
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.remember
import io.element.android.x.core.BuildConfig
// Note the inline function below which ensures that this function is essentially
// copied at the call site to ensure that its logging only recompositions from the
// original call site.
@Composable
inline fun LogCompositions(tag: String, msg: String) {
if (BuildConfig.DEBUG) {
val ref = remember { Ref(0) }
SideEffect { ref.value++ }
Log.d(tag, "Compositions: $msg ${ref.value}")
}
}
class Ref(var value: Int)