你需要使用
concat
和
timer
为了这个。与
海螺
它是在开始下一个流之前完成的第一个流。因此,它会进行更新,然后等待1秒,然后生成findById。
@Effect()
updateGeographicScope$ = this.actions$.pipe(
ofType<conventionsActions.PatchGeographicScope>(conventionsActions.ConventionActionTypes.PATCH_GEOGRAPHIC_SCOPE),
map(action => action.payload),
mergeMap(geographicScope => concat(
this.apiConvention.update(geographicScope).pipe(switchMapTo(EMPTY)),
timer(1000).pipe(switchMapTo(EMPTY)),
this.apiConvention.findById(geographicScope.externalId),
)),
map(convention => new conventionsActions.PatchSuccess({
id: convention.externalId,
changes: convention
})),
catchError(err => {
console.error(err.message);
return of(new conventionsActions.Failure({ concern: 'PATCH', error: err }));
}),
repeat(),
)),
);