Shakil Karim

    Shakil Karim

    1 year ago
    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
    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
    Adam Powell

    Adam Powell

    1 year ago
    What can make
    wordsList
    change while
    quizStated == true?
    Shakil Karim

    Shakil Karim

    1 year ago
    @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.
    Adam Powell

    Adam Powell

    1 year ago
    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