Mateusz Lewandowski
2016-08-12 07:38:43 UTC
Hi
Like in topic i hava a problem with Future method in ExchangeData Class
class looks following (it is only templeta becouse when i was writing this
post i had not my code)
string jsonData;
class ExchangeData
{
Future LoadData() async
{
HttpRequest req= new
...
req.send(...)
req.listen
(
jsonData=req.ResponseText;
)
}
String GetJson()
{
return this.jsonData;
}
}
I am trying to use it in
main() async
{
ExchangeData context=new ExchangeData();
await context.LoadData();
String response=context.GetJson();
}
The problem is that await does not waiting for data load and program
execution go to next instruction.
When i use LoadData like a function not method from class, it works.
How to wait for response from class method LoadData?
Maybe is there better way to return data from Future function?
Like in topic i hava a problem with Future method in ExchangeData Class
class looks following (it is only templeta becouse when i was writing this
post i had not my code)
string jsonData;
class ExchangeData
{
Future LoadData() async
{
HttpRequest req= new
...
req.send(...)
req.listen
(
jsonData=req.ResponseText;
)
}
String GetJson()
{
return this.jsonData;
}
}
I am trying to use it in
main() async
{
ExchangeData context=new ExchangeData();
await context.LoadData();
String response=context.GetJson();
}
The problem is that await does not waiting for data load and program
execution go to next instruction.
When i use LoadData like a function not method from class, it works.
How to wait for response from class method LoadData?
Maybe is there better way to return data from Future function?
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.