Combining an array of Futures #460
-
Is it possible to combine an array of let futures = [ Future.of(1), Future.of(2), Future.of(3) ];
Future.all(futures).fork(console.error, console.log);
//> [1, 2, 3]; Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
Future.parallel(2, [
Future.of(1), Future.of(2)
])
.fork(err, done) Sent from my Google Pixel using FastHub |
Beta Was this translation helpful? Give feedback.
-
Thank you! |
Beta Was this translation helpful? Give feedback.
-
What if I want to combine a heterogeneous tuple of futures? |
Beta Was this translation helpful? Give feedback.
-
@arsdragonfly I use chain (([a, [b, c]]) => ...)
(both (eventualA) (both (eventualB) (eventualC))) Alternatively, you can override the type of I don't want to change it, as it opens a door for the exact type of bugs users are trying to fight with TypeScript. I wish I could provide multiple typings files that users can choose from - a strict version and a loosy version, but the TypeScript maintainers feel this would be doing things in the wrong way. |
Beta Was this translation helpful? Give feedback.
-
@arsdragonfly Also note that const f = a => b => c => a + b + c;
lift3 (f) (eventualA) (eventualB) (eventualC)
//or for parallelism:
lift3 (f) (Par (eventualA)) (Par (eventualB)) (Par (eventualC)) |
Beta Was this translation helpful? Give feedback.
Sent from my Google Pixel using FastHub