Hi there. I am trying to build Async Tasks for our elmish application. I want to execute two async request in parallel and apply their responses to my results (applicative style). My problem is that I need to start two (or more) different Asyncs in parallel and I can not use Async.Parallel because the Asyncs are wrapping different Result Types. The problem is, that Async.StartChild does not seem to be implemented in Fable but I do not get any compile Errors or warnings in the browser dev tools.
The async requests are just never executed. Does anybody have a hint how to achieve what I want?
type Task<'Result, 'Error> =
Async<Result<'Result, 'Error>>
let private (<!>) = Result.map
let private (<*>) = Result.apply
let map2Parallel func taskA taskB =
async {
let! result1Async = taskA |> Async.StartChild // start first request but do not wait
let! result2Async = taskB |> Async.StartChild // start second request in parallel
let! result1 = result1Async
let! result2 = result2Async
let result =
func <!> result1 <*> result2
return result
}
Expected: Both async operations are started.
Actual: Nothing happens and there is neither a compile error nor a warning/error in the browser console
Hmm, you're right Async.StartChild is not implemented yet. I guess it should be possible to do it, I'll have a look. Thanks for pointing it out! 馃憤
Thanks!
Thanks to you! The fix will be published in next Fable 1.3 beta version. Hopefully today :)