How can I effectively assign data fetched from chrome.storage.sync.get
to my Angular component's variable?
Below is the code snippet of my component:
export class KTableComponent implements OnInit {
words: string[] = [];
constructor() {
}
ngOnInit(): void {
}
loadData() {
const words = this.words;
chrome.storage.sync.get({words: []}, function (result) {
Object.assign(words, result.words)
});
// The challenge lies in waiting for the asynchronous data retrieval process to finish
}
My objective here is to retrieve data and then re-render the component after assigning that data to the words
variable. It's evident that chrome.storage.sync.get
operates asynchronously, but what remains unclear is how to properly handle the wait for the returned results.