Async.RunSynchronously cannot be translated because this is simply not possible to implement in JavaScript. JS is single threaded by nature and the preferred way to write asynchronous code is to have callbacks. Async in F# basically saves you from the "callback hell" that arises when chaining async methods but it's semantics are a little different from what you get on .NET.

Therefore your best shot probably is to have the relevant code that deals with the async calls to live in the Async "monad" and sooner or later you will want to do something with that data that will have a side effect (e.g. appedning stuff to the DOM, adding items to a list etc.) and you can call Async.Start on that. You probably wouldn't want to block the user's tab and risk having your script shot down by the browser because it blocks the main thread for too long waiting for the result of a computation.

That being said, if you really need this, you can have your RPC call be synchronous by returning 'T instead of Async<'T> but that's almost never a good idea.

By on 4/18/2015 2:57 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper