I have A LOT of promises with some errors especially where you use resolve. I want the two blocks to be Async, One after another, but Its not exactly working. Is this too many promises? Am I implementing them right?
SetRoom(){
return new Promise((resolve,reject) =>{
var prom1= new Promise((resolve)=>{
console.log("attempting RoomProm1");
this.RoomLength=this.af.database.list('/Rooms');
this.RoomLength.take(1).subscribe(snap=>
{this.rLen=snap.length; resolve(true); });
});
prom1.then(_=>{
this.RoomLength.subscribe((snap)=>{this.RoomList = snap[this.rLen];
this.Room=this.af.database.list(`/Rooms/${this.RoomList.RoomNum}`);
});
prom1.then(_=>{
this.RoomKey=this.RoomList.RoomNum;
console.log('Key = ', this.RoomKey);
return resolve(true);
});
});
}