Does Dart have a scheduler? -
i looking @ dart server side point of view.
is there scheduler can execute isolates @ specific time or x times hour? thinking on lines of quartz in java world.
dart has few options delayed , repeating tasks, i'm not aware of port of quartz dart (yet... :)
here basics:
timer- run function after delayfuture- more robust, composable, functions return values "in future"stream- robust, composable streams of events. can periodic.
if have repeating task, recommend using stream on timer. timer not have error handling builtin, uncaught exceptions can bring down whole program (dart not have global error handler).
here's how use stream produce periodic results:
import 'dart:async'; main() { var stream = new stream.periodic(const duration(hours: 1), (count) { // every hour // return result of }); stream.listen((result) { // listen result of hourly task }); } you ask isolates. spawn isolate @ program start, , send message every hour. or, can spawn isolate @ program start, , isolate can run own timer or periodic stream.
Comments
Post a Comment