You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With `Task`s you can achieve the same using `sequence`. Both the `Promise.all` and the `sequence` approach run in parallel and wait until all results have arrived before they proceed.
If you need to run a list of `Task`s in sequence, i.e. you have to wait for one `Task` to finish before you run the second `Task`, you can use the `taskSeq` instance.
// ~~~~~ Argument of type '(Task<number> | Task<string>)[]' is not assignable to parameter of type 'Task<number>[]'.
96
96
// Type 'Task<number> | Task<string>' is not assignable to type 'Task<number>'.
97
97
// Type 'Task<string>' is not assignable to type 'Task<number>'.
@@ -104,9 +104,9 @@ We can use `sequenceT` or `sequenceS` instead.
104
104
```ts
105
105
import { apply, task } from"fp-ts";
106
106
107
-
apply.sequenceT(task.task)(task.of(1), task.of("hello")); // type is task.Task<[number, string]>
107
+
apply.sequenceT(task.ApplyPar)(task.of(1), task.of("hello")); // type is task.Task<[number, string]>
108
108
109
-
apply.sequenceS(task.task)({ a: task.of(1), b: task.of("hello") }); // type is task.Task<{ a: number; b: string; }>
109
+
apply.sequenceS(task.ApplyPar)({ a: task.of(1), b: task.of("hello") }); // type is task.Task<{ a: number; b: string; }>
110
110
```
111
111
112
112
## Work with a list of dependent tasks
@@ -129,7 +129,7 @@ pipe(
129
129
If you have a list of items that you need to `map` over before running them in `sequence`, you can use `traverse`, which is a shortcut for doing both operations in one step.
0 commit comments