Reputation: 123
I'm blocked how to implement this specification :
I call a method update() :
this.contratService.update(lineSelected.id).subscribe(response => {
if (response.status === 201) {
....
}
}, error => {
console.log('Error in contrat update');
});
I want to wait 30 seconds after update called before to show another error.
How can I implement this feature?
Note: I understand that setTimeout, execute an instruction after a certain time and note wait a certain time after a method was called
Thank's
Upvotes: 0
Views: 764
Reputation: 8558
You can use timeout()
pipeable operator of rxjs
;
import { timeout } from 'rxjs/operators';
...
this.contratService.update(lineSelected.id)
.pipe(
timeout(30000)
)
.subscribe(response => {
if (response.status === 201) {
....
}
}, error => {
console.log('Error in contrat update');
});
Ref: https://rxjs-dev.firebaseapp.com/api/operators/timeout
Upvotes: 1