After successfully working on an effect, I now face the challenge of chaining it with a service called in a subsequent action after updating the state in the initial action through a reducer.
Here is the effect code:
@Effect()
uploadSpecChange$: Observable<Action> = this.actions$.pipe(
ofType(AppActions.WorkspaceActionTypes.UploadChange),
switchMap((x: any) => {
let f = new FileReader();
f.readAsText(x.payload);
return fromEvent(f, 'load');
}),
map((result: any) => {
const raw = (<FileReader>result.target).result as string;
const res = JSON.parse(raw);
// console.log(res);
return
new AppActions.UploadComplete(res),
new AppActions.PerformCalc()
})
);
I included the second action but am currently encountering an error related to Observables.