async-ajax-0.2.0.0: Crossbrowser async AJAX Bindings for GHCJS

Safe HaskellNone
LanguageHaskell2010

JavaScript.Ajax.Async

Synopsis

Documentation

sendRequestAsync :: StdMethod -> Text -> Maybe RequestBody -> Maybe ContentType -> IO (Async AjaxResponse) Source #

Send an ajax request provided a HTTP-Method, a target url, optional a request body and content type

data StdMethod :: * #

HTTP standard method (as defined by RFC 2616, and PATCH which is defined by RFC 5789).

Constructors

GET 
POST 
HEAD 
PUT 
DELETE 
TRACE 
CONNECT 
OPTIONS 
PATCH 

data Async a :: * -> * #

An asynchronous action spawned by async or withAsync. Asynchronous actions are executed in a separate thread, and operations are provided for waiting for asynchronous actions to complete and obtaining their results (see e.g. wait).

Instances

Functor Async 

Methods

fmap :: (a -> b) -> Async a -> Async b #

(<$) :: a -> Async b -> Async a #

Eq (Async a) 

Methods

(==) :: Async a -> Async a -> Bool #

(/=) :: Async a -> Async a -> Bool #

Ord (Async a) 

Methods

compare :: Async a -> Async a -> Ordering #

(<) :: Async a -> Async a -> Bool #

(<=) :: Async a -> Async a -> Bool #

(>) :: Async a -> Async a -> Bool #

(>=) :: Async a -> Async a -> Bool #

max :: Async a -> Async a -> Async a #

min :: Async a -> Async a -> Async a #

wait :: Async a -> IO a #

Wait for an asynchronous action to complete, and return its value. If the asynchronous action threw an exception, then the exception is re-thrown by wait.

wait = atomically . waitSTM

waitCatch :: Async a -> IO (Either SomeException a) #

Wait for an asynchronous action to complete, and return either Left e if the action raised an exception e, or Right a if it returned a value a.

waitCatch = atomically . waitCatchSTM

cancel :: Async a -> IO () #

Cancel an asynchronous action by throwing the ThreadKilled exception to it. Has no effect if the Async has already completed.

cancel a = throwTo (asyncThreadId a) ThreadKilled

Note that cancel is synchronous in the same sense as throwTo. It does not return until the exception has been thrown in the target thread, or the target thread has completed. In particular, if the target thread is making a foreign call, the exception will not be thrown until the foreign call returns, and in this case cancel may block indefinitely. An asynchronous cancel can of course be obtained by wrapping cancel itself in async.