setTimeout method

int setTimeout(
  1. String vmId,
  2. VoidCallback function,
  3. int milliseconds
)

Implementation

int setTimeout(String vmId, VoidCallback function, int milliseconds) {
  final Map<int, JSTimeout> cache = _globalCache.putIfAbsent(vmId, () => <int, JSTimeout>{});
  final JSTimeout timeout = JSTimeout(function, milliseconds);
  final int timeoutId = timeout.id;
  cache[timeoutId] = timeout;
  timeout.emit().then((_) {
    cache.remove(timeoutId);
  });
  return timeoutId;
}