Is there any way I Can fetch the older value which...
# compose
s
Is there any way I Can fetch the older value which was computed by derivedStateOf? I want to return older value which was computed by derivedStateOf When there is a certain condition is true otherwise new value,
I have these State variables
Copy code
var wordsList by mutableStateOf<List<Objects>>(emptyList())
var quizStated by mutableStateOf(false)
val quizList by derivedStateOf { if(!quizStated) prepareQuiz(wordsList))  }
I want to keep the quiz list unchanged when is quizStated
a
What can make
wordsList
change while
quizStated == true?
s
@Adam Powell When quiz is started, there is separate screen where points are added or minus on Database, Which triggered room query and update wordsList.
a
derivedStateOf will not help you for retaining an old value here. Try to avoid updating the inputs of
quizList
at all if you would like to keep it from updating
👍 1