Okay, so is there a way to return a value from a function - the way return does - but not stop the function - the way return does?
I need this so I can keep returning values every so often.
My code looks like:
loopingTitleTextHandler = () => {
const title = ["good", "cool", "887H", "Vertical"];
for (i = 0; i < 999999; i++) {
var j = i%4;
// loopingTitleTextHandler() // calls itself before return terminates execution
return title[j]; //return 0,1,2,3 in a loop with 3 second delay
}
}
My React Component
<ShowTitle size={230}
title={this.loopingTitleTextHandler()}
color="#FDA7DC" />
Edit: I'm after a solution that solves this problem in the function like this python answer: Return multiple values over time but using ES6.
import time
def myFunction(limit):
for i in range(0,limit):
time.sleep(2)
yield i*i
for x in myFunction(100):
print( x )