Angular 4 个 http 批量请求
Angular 4 http batch requests
为了优化我的 API 调用,我想使用此模块进行批量请求
https://github.com/jonsamwell/ngx-http-batcher#examples。
根据示例,配置在 AppModule 中设置。
export function httpBatchConfigurationFactory() {
return new HttpBatchConfigurationCollection([
new HttpBatchConfiguration({
rootEndpointUrl: "https://api.myservice.com",
batchEndpointUrl: "https://api.myservice.com/$batch"
})]);
};
并且在供应商中,我设置了
{ provide: HttpBatchConfigurationCollection, useFactory: httpBatchConfigurationFactory },
{ provide: Http, useClass: HttpBatcher }
当此配置为静态时,一切正常。
我的应用程序仅在用户登录到应用程序后才识别 rootEnPointUrl。
如何在用户身份验证后向此 HttpBatchConfigurationCollection 添加新的 HttpBatchConfiguration?
为什么不使用可注入服务而不是在模块设置期间提供工厂?这样即使在应用程序初始化后,您也可以随时更改配置。
为了优化我的 API 调用,我想使用此模块进行批量请求 https://github.com/jonsamwell/ngx-http-batcher#examples。 根据示例,配置在 AppModule 中设置。
export function httpBatchConfigurationFactory() {
return new HttpBatchConfigurationCollection([
new HttpBatchConfiguration({
rootEndpointUrl: "https://api.myservice.com",
batchEndpointUrl: "https://api.myservice.com/$batch"
})]);
};
并且在供应商中,我设置了
{ provide: HttpBatchConfigurationCollection, useFactory: httpBatchConfigurationFactory },
{ provide: Http, useClass: HttpBatcher }
当此配置为静态时,一切正常。 我的应用程序仅在用户登录到应用程序后才识别 rootEnPointUrl。
如何在用户身份验证后向此 HttpBatchConfigurationCollection 添加新的 HttpBatchConfiguration?
为什么不使用可注入服务而不是在模块设置期间提供工厂?这样即使在应用程序初始化后,您也可以随时更改配置。