This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mixin WorkMixin { | |
void work(); | |
void start() { | |
this.work(); | |
} | |
} | |
class Updater with WorkMixin { | |
@override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/npm/download-counts | |
import 'dart:html'; | |
const npmDownloadBase = 'https://api.npmjs.org/downloads/point/'; | |
void fetchDownloadCounts({String repo='koa', String period='last-week'}) async { | |
var resp = await HttpRequest.getString('$npmDownloadBase${period}/$repo'); | |
print(resp); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"sync" | |
) | |
type ( | |
Executor interface { | |
Execute() error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
main() { | |
Future<int> future = Future(() => 1024); | |
future.then((val) => print(val)) | |
.catchError((err) => print(err)); | |
print("Finished!"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
main() async { | |
Future<int> future = Future(() => 1024); | |
try { | |
print(await future); | |
} catch(err) { | |
print(err); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:core'; | |
import 'dart:async'; | |
Future<bool> validateSender = Future<bool>.delayed(Duration(seconds: 1), () { | |
print('validate sender...'); | |
return true; | |
}); | |
Future<bool> validateReceiver = Future<bool>.delayed(Duration(seconds: 3), () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:core'; | |
import 'dart:async'; | |
Future<bool> exception = Future<bool>.delayed(Duration(seconds: 1), () { | |
print('Somehow, a exception happend...'); | |
throw 'Just a Exception, freeze!'; | |
}); | |
Future procedure = Future(() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
main() { | |
StreamController controller = StreamController(); | |
controller.stream.listen((val) { | |
print('Event received: $val'); | |
}, onDone: () { | |
print('Stream done'); | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
main() { | |
StreamTransformer transformer = StreamTransformer<num, num>.fromHandlers( | |
handleData: (num val, EventSink sink) { | |
sink.add(val + 1); | |
} | |
); | |
StreamController controller = StreamController<num>(); | |
Stream transformed = controller.stream.transform(transformer); |
OlderNewer