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

Commit 4f96711

Browse files
committed
startWith: don't use Scheduler.currentThread
More precisely, don't use the implementation of concat that uses Scheduler.currentThread. This implementation uses Scheduler.immediate, but only for the concat--startWith's scheduler is still used for emitting the actual elements prepended to the observable.
1 parent f5b6e86 commit 4f96711

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

src/core/linq/observable/startwith.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
scheduler = immediateScheduler;
1616
}
1717
for(var args = [], i = start, len = arguments.length; i < len; i++) { args.push(arguments[i]); }
18-
return enumerableOf([observableFromArray(args, scheduler), this]).concat();
18+
return observableConcat.apply(null, [observableFromArray(args, scheduler), this]);
1919
};

tests/observable/startwith.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,29 @@
127127
);
128128
});
129129

130+
test('startWith is unaffected by currentThread scheduler', function () {
131+
var scheduler = new TestScheduler();
132+
133+
var xs = scheduler.createHotObservable(
134+
onNext(150, 1),
135+
onNext(220, 2),
136+
onCompleted(250)
137+
);
138+
139+
var results;
140+
141+
Rx.Scheduler.currentThread.schedule(null, function () {
142+
results = scheduler.startScheduler(function () {
143+
return xs.startWith(scheduler, 1);
144+
});
145+
});
146+
147+
results.messages.assertEqual(
148+
onNext(201, 1),
149+
onNext(220, 2),
150+
onCompleted(250)
151+
);
152+
153+
});
154+
130155
}());

0 commit comments

Comments
 (0)