constuserIds = [1, 2, 3, 4, 5]; // synchronous list of user id-s
consti = pipe( toAsync(userIds), // make pipeline asynchronous map(id=>myService.getUserData(id)), // map into promises aggregate(list=>Promise.all(list)), // resolve all promises wait(), // resolve the list spread() // emit each resolved value );
forawait(constuserofi) { console.log(user); // print details for each user }
When the value is a
Promise
, it is resolved, or else returned as is, i.e. the same logic as for JavaScript operatorawait
.In case you want all promises resolved before emitting values: