I am new and do not yet understand how to handle the asynchronous methods correctly. Is there a way to synchronize the .Send or how to solve the following problem on clean?
I retrieve the account details with my method "GetAccountDetails" as follows and save them in my own GSPlayer object.The code also works (shortened):
new AccountDetailsRequest().Send((response) => {
if (response.HasErrors)
{
GameSparksAvailable = false;
}
else
{
Currency1 = response.Currency1;
}});
If I want to retrieve the data in another place, for example after a purchase, I always get zero as the output of "Currency1" because the code is executed faster than the data is retrieved:
How is it possible to retrieve the data and process it directly in the next line?
1 Comment
C
Christian Eichinger
said
about 4 years ago
In the following situation I have the same problem.The player should press a button to buy something.For this a CloudCode is executed.But I would like to prevent the user from pressing the buy button too fast in quick succession.He has to wait until he receives the confirmation of the successful purchase.
Christian Eichinger
Hello,
I am new and do not yet understand how to handle the asynchronous methods correctly.
Is there a way to synchronize the .Send or how to solve the following problem on clean?
I retrieve the account details with my method "GetAccountDetails" as follows and save them in my own GSPlayer object. The code also works (shortened):
If I want to retrieve the data in another place, for example after a purchase, I always get zero as the output of "Currency1" because the code is executed faster than the data is retrieved:
How is it possible to retrieve the data and process it directly in the next line?