FP-ts: execute tasks in sequence

65 views Asked by At

I'm newer in fp-ts use.

In my code, I use sequenceS in order to execute tasks in sequence, but what I obtain is that handlePage terminates before executeImport.

Is there a way to be sure that executeImport ends before the execution of other tasks?

import { pipe } from 'fp-ts/function';
import { sequenceS } from "fp-ts/Apply";
import * as TE from 'fp-ts/TaskEither';

export const getDatas = (config) : TE.TaskEither<Error | Errors, {
    res: {
        pool: ConnectionPool;
        operators: IOperatorDB[];
        orders: IMachineOrderItem[];
        documents: IMachineDocument[];
        stages: IProdStage[];
        aImgs: IAImg[];
        bImgs: IBImg[];
        calendarEvents: ICalendarEvent[];
        page: IPage[];
    };
    handleImages: Promise<void>;
    handleCalendarEvent: Promise<void>;
    handlePage: Promise<void>;
}> =>
sequenceS(TE.ApplicativeSeq)({
    res: executeImport(config),
    handleImages: TE.right(handleImages()),
    handleCalendarEvent: TE.right(handleEvents()),
    handlePage: TE.right(handlePage()),
});
0

There are 0 answers