Skip to content
This repository was archived by the owner on Apr 20, 2018. It is now read-only.

Commit 4cdee92

Browse files
committed
* Switched to generateWith*Time methods to use scheduleRecursiveWith*AndState
* Moved several variables into the inner scope.
1 parent b241e17 commit 4cdee92

2 files changed

Lines changed: 12 additions & 18 deletions

File tree

src/core/linq/observable/generatewithabsolutetime.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,9 @@
2121
isScheduler(scheduler) || (scheduler = timeoutScheduler);
2222
return new AnonymousObservable(function (observer) {
2323
var first = true,
24-
hasResult = false,
25-
result,
26-
state = initialState,
27-
time;
28-
return scheduler.scheduleRecursiveWithAbsolute(scheduler.now(), function (self) {
29-
hasResult && observer.onNext(result);
24+
hasResult = false;
25+
return scheduler.scheduleRecursiveWithAbsoluteAndState(initialState, scheduler.now(), function (state, self) {
26+
hasResult && observer.onNext(state);
3027

3128
try {
3229
if (first) {
@@ -36,15 +33,15 @@
3633
}
3734
hasResult = condition(state);
3835
if (hasResult) {
39-
result = resultSelector(state);
40-
time = timeSelector(state);
36+
var result = resultSelector(state);
37+
var time = timeSelector(state);
4138
}
4239
} catch (e) {
4340
observer.onError(e);
4441
return;
4542
}
4643
if (hasResult) {
47-
self(time);
44+
self(result, time);
4845
} else {
4946
observer.onCompleted();
5047
}

src/core/linq/observable/generatewithrelativetime.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,9 @@
2121
isScheduler(scheduler) || (scheduler = timeoutScheduler);
2222
return new AnonymousObservable(function (observer) {
2323
var first = true,
24-
hasResult = false,
25-
result,
26-
state = initialState,
27-
time;
28-
return scheduler.scheduleRecursiveWithRelative(0, function (self) {
29-
hasResult && observer.onNext(result);
24+
hasResult = false;
25+
return scheduler.scheduleRecursiveWithRelativeAndState(initialState, 0, function (state, self) {
26+
hasResult && observer.onNext(state);
3027

3128
try {
3229
if (first) {
@@ -36,15 +33,15 @@
3633
}
3734
hasResult = condition(state);
3835
if (hasResult) {
39-
result = resultSelector(state);
40-
time = timeSelector(state);
36+
var result = resultSelector(state);
37+
var time = timeSelector(state);
4138
}
4239
} catch (e) {
4340
observer.onError(e);
4441
return;
4542
}
4643
if (hasResult) {
47-
self(time);
44+
self(result, time);
4845
} else {
4946
observer.onCompleted();
5047
}

0 commit comments

Comments
 (0)