Мне приходится вызывать службу несколько раз, для forEach, метода, который имеет подписку внутри (вызов http), и мне приходится каждый раз ждать окончания предыдущего вызова. Это код:
itemDefaultConfiguration.command = (onclick) => {
this.createConfiguration(configuration.components);
//wait the end of createConfiguration method that has subscribe (http call) inside
this.initializeAllComponents(configuration.components)
};
initializeAllComponents(components: Agent[]) {
components.forEach(agent => {
this.componentService.setAgent(agent);
this.componentService.clearAnyOneOfIndex();
// wait the end of setAgent method that has subscribe(http call) inside
})
}
внутри componentService:
setAgent(agent: Agent) {
this.agent = agent;
this.selectComponent(agent.name, undefined, "/", "/", environment.maxLevelJsonSchema);
}
, и selectComponent подписан.
selectComponent(agentName: string, propName: string, schemaPath: string, dataPath: string, deepLevel: number) {
this.getComponentSchema(this.agentName, schemaPath, deepLevel)
.subscribe((responseSchema) => {
this.getDataFailure(propName, dataPath, responseSchema);
});
}
Можете ли вы мне помочь? Спасибо