I want each iteration to update items when I push an object to an array of objects

22 Views Asked by At

I want to add 1000 objects to an array of objects and I iterate this array with each iterator

I want each item pushed to be followed by updated view in the browser

1

There are 1 best solutions below

0
ZenitoGR On

while I was trying to make a simple example of my question I found the solution to my question: my solution using setTimeout() and for loop:

for (var i = 1; i<=1000; i++){
setTimeout(() => { ractive.push('arrayName',{key:value,key2:value}), i * 100}
}

jsfiddle live demo

the source for the setTimeout() idea: Delay, Sleep, Pause & Wait in JavaScript - sitepoint.com