I've been attempting to invoke a function to check whether a company has reached their maximum allowed registrations, but every time I call it, nothing gets printed. Can anyone point out what mistake I might be making?
Thanks!
validateRegistration(company: string) {
var snapshotMaxRegs = this.db.object(`companies/${company}/maxregs`,{ preserveSnapshot: true})
return snapshotMaxRegs.map(snapshot => {
console.log('maxRegs = '+ snapshot.val())
return snapshot.val();
});
}
getCompanyRegistrationsCount(company: string){
var snapshotCountRegs = this.db.object(`companies/${company}/countregs`,{ preserveSnapshot: true})
return snapshotCountRegs.map(snapshot => {
console.log('currRegs = '+ snapshot.val())
return snapshot.val();
});
}
checkIfMaxRegsReached(company: string){
return Observable.forkJoin([
this.getCompanyRegistrationsCount(company),
this.validateRegistration(company)
]).map((joined)=>{
let countRegs = joined[0];
let maxRegs = joined[1];
return countRegs >= maxRegs;
})
}
Now I need to subscribe to the maxRegsReached method in order to see the results, but for some reason, nothing is being printed...
this.checkIfMaxRegsReached('01').subscribe(result => {
console.log(result) //true or false
})