I have 2 observables, and I need to get each observable data only one time.
What I did is subscription inside a subscription, although they can be executed in the same time (in parallel).
let table = this.af.database.object('tables');
table.subscribe((tableData) => {
let section_seats = this.af.database.object('sections').take(1)
.subscribe((sectionData) => {
//Here I'm Using tableData & sectionData
});
});
The code above works great, but they are not executed in the same time although they can.
How I can execute both of the observables in the same time then use the data received from both of them?
Update: Using forkJoin() doing nothing (no console log from the following code)
var source = Observable.forkJoin(
this.af.database.object('tables'),
this.af.database.object('sections')
);
var subscription = source.subscribe(
function (x) {
console.log('Next: %s', x);
},
function (err) {
console.log('Error: %s', err);
},
function () {
console.log('Completed');
});