I have a few observables. And I need to know which one triggered the subscribe.
Observable.combineLatest(
this.tournamentsService.getUpcoming(),
A quite clean and "rx"-way of achieving this is by using the timestamp operator http://reactivex.io/documentation/operators/timestamp.html
Example code
sourceObservable
.pipe(
timestamp(), // wraps the source items in object with timestamp of emit
combineLatest( otherObservable.pipe( timestamp() ), function( source, other ) {
if( source.timestamp > other.timestamp ) {
// source emitted and triggered combineLatest
return source.value;
}
else {
// other emitted and triggered combineLatest
return other.value;
}
} ),
)
If more than two observables are involved in the combineLatest() sorting them by timestamp would enable to detect which one triggered the combineLatest().