convention for Future/Stream that have no value

40 views
Skip to first unread message

Lex Berezhny

unread,
Dec 16, 2014, 12:29:15 PM12/16/14
to misc
Hello,

I was wondering if there was any general convention for what to do when you only care to announce that something happened but there is really no associated value.

I know for the listener you can use underscore:

success.then((_) {
  print('Yippy!!');
});

But what about in the completer?

success_completer.complete(null);
success_completer.complete(true);

Is there a convention that people are using for this? I suppose 'null' is more obvious that the value is irrelevant, using true might imply that there could also be a false?

 - lex

Lasse R.H. Nielsen

unread,
Dec 16, 2014, 12:43:32 PM12/16/14
to mi...@dartlang.org
The convention is to use null as the value, and since the argument to complete is optional, that can be just:
  success_completer.complete();


/L
-- 
Lasse R.H. Nielsen - l...@google.com  
'Faith without judgement merely degrades the spirit divine'
Google Denmark ApS - Frederiksborggade 20B, 1 sal - 1360 København K - Denmark - CVR nr. 28 86 69 84

--
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

To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.


--
Lasse R.H. Nielsen - l...@google.com  
'Faith without judgement merely degrades the spirit divine'
Google Denmark ApS - Frederiksborggade 20B, 1 sal - 1360 København K - Denmark - CVR nr. 28 86 69 84
Reply all
Reply to author
Forward
0 new messages