Reputation: 331
this.btSerial.connect(macAddress).subscribe( --- Add 5 secs max wait if no respnse then goes to next
_=>{
this.btSerial.write(resultByte).then( --- Add 5 secs max wait if no respnse then goes
data=>{
this.alert.presentAlert("succe","Succ");
this.btSerial.disconnect();
},err=>{
this.alert.presentAlert("print",err);
}
)},err=>{
this.alert.presentAlert("Connect", err);
});
I have a ionic application which returns observable and promise .. In both i have to max 5 secs to waits and and then goes next iteration ..Can u please help me get the correct code
Upvotes: 1
Views: 308
Reputation: 1600
I recommand the timer operator provided by Rxjs :
this.btSerial.connect(macAddress).subscribe( --- Add 5 secs max wait if no const
_=>{
waitForNextSubs = timer(5000);
waitForNextSubs.subscribe(x => {
this.btSerial.write(resultByte).then( --- Add 5 secs max wait if no respnse then goes
data=>{
this.alert.presentAlert("succe","Succ");
this.btSerial.disconnect();
},err=>{
this.alert.presentAlert("print",err);
}
)},err=>{
this.alert.presentAlert("Connect", err);
});
});
Upvotes: 1