0
こんにちは私は "loadFullService $"の新しいアクション "LoadConfig"をディスパッチしたいと思います。1つのエフェクトから複数のアクションをディスパッチする
どのようにすればいいですか?コンストラクタで
@Effect()
loadFullService$: Observable<Action> = this.actions$
.ofType<servicesActions.LoadFullService>(servicesActions.LOAD_FULL_SERVICE)
.switchMap(action => {
return this.apiService
.loadFullService(action.payload)
.map((service: Service) => new servicesActions.LoadFullServiceSuccess(service))
.catch(error => of(new servicesActions.LoadFailureAction(error)));
})
;
@Effect()
loadConfig$: Observable<Action> = this.actions$
.ofType<servicesActions.LoadConfig>(servicesActions.LOAD_CONFIG)
.switchMap(action => {
console.log("action config", action);
return this.apiService
.loadConfig(action.id, action.name)
.map((config: Configuration) => new servicesActions.LoadConfigSuccess(config))
.catch(error => of(new servicesActions.LoadConfigFailure(error)));
});
Thxをuが
私が試したが、私は実際に何をすべきでしょうか? .do(this.store.dispatch(新しいservicesActions.LoadConfig(action.id、action.name))))を実行しますか? –
はい、回答を更新しました –
Thx u!最後の質問私は "LoadFullService"アクションの戻り値である "name"が必要ですが、戻すことはできますか? –