Joakim Forslund
09/28/2021, 2:50 PMfun getOptionFlow(configurationName: String): Flow<OptionInfo?> {
        var oldOptionlist = getOptionListBlocking(configurationName)
        return datastore.data.catch { exception ->
            if (exception is IOException) {
                emit(Settings.getDefaultInstance())
            } else {
                throw exception
            }
        }.map { settings ->
            val result = settings.configurationsList.first { it.name.equals(configurationName) }.optionList
            val difference = result.filter { !oldOptionlist.contains(it) }
            oldOptionlist = result
            difference.firstOrNull()
        }
}
Now this is pretty ugly, and I am ashamed of the monster I have created, is there a more flow like solution that does not need to result saving a local variable?