call onFinish in reproduceriter

This commit is contained in:
Alon Zakai 2012-09-07 17:48:23 -07:00
Родитель c31aaf5c1b
Коммит 5ec60ca0ee
1 изменённых файлов: 10 добавлений и 0 удалений

Просмотреть файл

@ -265,6 +265,7 @@ var Recorder = (function() {
if (recorder.randoms.length > 0) { if (recorder.randoms.length > 0) {
return recorder.randoms.pop(); return recorder.randoms.pop();
} else { } else {
recorder.finish();
throw 'consuming too many values!'; throw 'consuming too many values!';
} }
}; };
@ -273,6 +274,7 @@ var Recorder = (function() {
if (recorder.dnows.length > 0) { if (recorder.dnows.length > 0) {
return recorder.dnows.pop(); return recorder.dnows.pop();
} else { } else {
recorder.finish();
throw 'consuming too many values!'; throw 'consuming too many values!';
} }
}; };
@ -280,6 +282,7 @@ var Recorder = (function() {
if (recorder.pnows.length > 0) { if (recorder.pnows.length > 0) {
return recorder.pnows.pop(); return recorder.pnows.pop();
} else { } else {
recorder.finish();
throw 'consuming too many values!'; throw 'consuming too many values!';
} }
}; };
@ -291,6 +294,13 @@ var Recorder = (function() {
recorder.addListener = function(target, which, callback, arg) { recorder.addListener = function(target, which, callback, arg) {
recorder['event' + which] = callback; recorder['event' + which] = callback;
}; };
// Finish
recorder.finish = function() {
if (recorder.onFinish) {
recorder.onFinish();
recorder.onFinish = null;
}
};
} }
return recorder; return recorder;
})(); })();