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

Commit 3f12183

Browse files
Merge pull request #953 from xgrommx/patch-1
Update spawn.js
2 parents b8a9aaf + 5b7939d commit 3f12183

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

src/core/linq/observable/spawn.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,16 @@
4040
o.onCompleted();
4141
return;
4242
}
43-
var value = toObservable.call(self, ret.value);
43+
var obs = toObservable.call(self, ret.value);
44+
var value = null;
45+
var hasValue = false;
4446
if (Observable.isObservable(value)) {
45-
g.add(value.subscribe(processGenerator, onError));
47+
g.add(value.subscribe(function(val) {
48+
hasValue = true;
49+
value = val;
50+
}, onError, function() {
51+
hasValue && processGenerator(value);
52+
}));
4653
} else {
4754
onError(new TypeError('type not supported'));
4855
}
@@ -64,9 +71,13 @@
6471
}
6572

6673
function arrayToObservable (obj) {
67-
return Observable.from(obj)
68-
.flatMap(toObservable)
69-
.toArray();
74+
return Observable.from(obj).concatMap(function(o) {
75+
if(Observable.isObservable(o) || isObject(o)) {
76+
return toObservable.call(null, o);
77+
} else {
78+
return Rx.Observable.just(o);
79+
}
80+
}).toArray();
7081
}
7182

7283
function objectToObservable (obj) {

0 commit comments

Comments
 (0)