I have the following two subscriptions:
this.service1.source1.subscribe(countries => {
this.filteredData = [];
countries.forEach(country => {
this.filteredData = this.data.filter(user => {
return user.country == country;
});
});
});
this.service2.source2.subscribe(companies => {
companies.forEach(company => {
this.filteredData = [];
this.filteredData = this.data.filter(user => {
return user.company == company;
});
});
});
where source1 and source2 are BehaviorSubject and both events are being caught by subscribe.
I want to combine both subscriptions because I want to filter data depending on both results returned by subscribe
I tried forkJoin and zip
zip([this.service1.source1, this.service1.source2]).subscribe(results => {
console.log('zip results:', results);
});
forkJoin([this.service1.source1, this.service1.source2]).subscribe(results => {
console.log('forkJoin results:', results);
});
But with those (zip & forkJoin) I noticed I am not even getting anything on the console, as if subscribe is not getting executed when events are emitted.
How can I combine the results of both sources into one subscription?