最佳答案
Being new to RxJS I often create a subject which holds values in the future, but is initially undefined
. It can only be undefined
the first time. I currently use a filter
to skip undefined
values, but this is quite cumbersome as I do it everywhere as I need only once. (Maybe I do something wrong here?) Can I somehow subscribe to mySubject
only after it got its first value via onNext
?
var mySubject = new Rx.BehaviorSubject(undefined);
mySubject.filter(function(value) {
return value !== undefined;
}).subscribe(function(value) {
// do something with the value
});