How do I do the equivalent of setTimeout + clearTimeout in Dart?

46 views
Skip to first unread message

Danny Tuppeny

unread,
Nov 21, 2014, 9:14:42 AM11/21/14
to mi...@dartlang.org

(Posted on StackOverflow too)

I'm porting some JavaScript to Dart. I have code that uses window.setTimeout to run a callback after a period of time. In some situations; that callback gets canceled via window.clearTimeout.

What is the equivalent of this in Dart? I can use new Future.delayed to replace setTimeout, but I can't see a way to cancel this. Nor can I find away to call clearTimeout from Dart.

Matthew Butler

unread,
Nov 21, 2014, 9:34:20 AM11/21/14
to mi...@dartlang.org
As answered on SO. Use Timer for a timeOut that can be cancelled. Use Delayed for one you don't expect to need to cancel. 
Reply all
Reply to author
Forward
Message has been deleted
0 new messages