Hey
I have a question about a coroutine I’m doing.
My coroutine receives one parameter, sends a UnityWebRequest based on that parameter and logs its response
public IEnumerator UpdateApi(int value)
{
if (_lastSentValue >= value)
yield break;
var url = GetUrl(value);
using (UnityWebRequest req = UnityWebRequest.Get(url))
{
yield return req.SendWebRequest();
while (!req.isDone)
yield return null;
string response = Encoding.Default.GetString(req.downloadHandler.data);
Debug.Log(response);
_lastSentValue = value;
}
}
In my update function I have
StartCoroutine(UpdateApi(_viewModel.Value));
_viewModel.Value can change constantly and I’m wondering how it will affect the coroutine?
if the coroutine was started with _viewModel.Value with a value of 20, and before it finished it is called again with 40.
What will happen?
thanks!