heavylist 0.1.1 heavylist: ^0.1.1 copied to clipboard
An asynchronous or delayed loop with resume and pause capabilities.Control how fast or slow loop progresses
import 'dart:async';
import 'package:heavylist/heavylist.dart';
main() {
HeavyList<int> abc = new HeavyList<int>([1, 2, 3, 4, 5, 6]);
abc.pause();
new Timer(new Duration(milliseconds: 2000), () {
print('resuming');
abc.resume();
});
abc.loop(new Duration(milliseconds: 1000), (List<int> origin) {
print('------------');
print(origin);
print('------------');
abc.empty();
}, (int item, Function resume) {
new Timer(new Duration(milliseconds: 100), () {
//simulating an asynchronous call
print(item);
print('completed ${item}');
abc.clearRegistered();
//move to next item
resume();
});
});
//Add an item and restart loop,please note a new subscription to begun and clear is needed here
new Timer(new Duration(seconds: 20), () {
abc.addItemLoop(7);
});
}