Advertisement
Guest User

Untitled

a guest
May 21st, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.60 KB | None | 0 0
  1. // Well ... no. Await is non-blocking. Your example is misleading once again :-)
  2.  
  3. // Example A:
  4. ranBool(5).then((ret) => print(ret.toString()));
  5. new Timer(const Duration(seconds: 2), () {
  6.   print('timer finished');
  7. });
  8.  
  9. // is NOT the same as Example B:
  10. if (await ranBool(5))
  11.   print('true');
  12. else
  13.   print('false');
  14. new Timer(const Duration(seconds: 2), () {
  15.   print('timer finished');
  16. });
  17.  
  18. // Without the await magic, Example B would look like this (Example C):
  19. ranBool(5).then((ret) {
  20.   print(ret.toString()));
  21.   new Timer(const Duration(seconds: 2), () {
  22.     print('timer finished');
  23.   });
  24. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement