I have a set of POSTs that I am trying to send in sequence of one another, something like:
if (this.ifoForm.valid) {
if (this.otherCheck && (!this.selectedLang || !this.selectedInterp)) {
swal('Error!', 'Please choose Language and Interpreter!', 'error');
} else {
// create CallTracker entity
this.createCallLog();
// create CTClient entity
this.createCTClient();
// create CTTeln entity
this.createCTTelns();
// create CTClientOffence entities
this.createCTClientOffences();
}
}
The thing is that CTClient
cannot be created w/o a CallTracker
(call log) entity, same with CTTelns
. As well CTClientOffences
cannot be created until CallTracker
and CTClient
entities are present.
I have in my container component entity objects that are instantiated when the POSTs return:
private callLog: CallTracker;
private logClient: CTClient;
private logTelns: CTTeln[];
private logCharges: CTClientOffence[];
For example:
public onLogNotify(callLog): void {
// add new CallTracker entity to database
this._callTrackerService.addLog(callLog)
.subscribe(
res => this.callLog = res,
err => console.log(err)
);
}
My question is: can I use these objects to restrict the call to the subsequent POSTS until the appropriate objects are instantiated? i.e. what can I use instead of .timeout()
:
public onClientNotify(client): void {
// add new CTClient entity to database
this._ctClientService.addCTClient(client)
.timeout(2000) // wait for CallTracker entity to be made
.subscribe(
res => this.logClient = res,
err => console.log(err)
);
}