Ioni c 4: Конфликт данных при записи в хранилище - PullRequest
0 голосов
/ 19 июня 2020

Я новичок в ioni c, angular и javascript, у меня есть функция ionOnchange, которая обновляет question при хранении, но когда функция постоянно запускается, значение памяти неверное. Заранее спасибо

async appendQuestion(questionId) {
  console.log("start", questionId)
  let questions = await this.storage.get("questions").then(data => {return data})
  questions.push(questionId)
  await this.storage.set("questions", questions)
  console.log("end", questionId)
}

appendQuestion(1)
appendQuestion(2)
appendQuestion(3)
start 1
end 1
start 2
start 3
end 2
end 3

Значение «questions» составляет [1, 3]

Мой ожидаемый результат: [1, 2, 3]

start 1
end 1
start 2
end 2
start 3
end 3
...