-
Notifications
You must be signed in to change notification settings - Fork 78
Closed
Labels
type: enhancementA new feature or addition.A new feature or addition.
Description
A ticket to discuss the API.
The other day I was thinking something like this could work:
ajax :: forall e. AjaxRequest -> Aff (ajax :: AJAX | e) AjaxResponse
type AjaxRequest = {
url :: String,
method :: Method,
headers :: StrMap String,
content :: Content,
...
}
type AjaxResponse = {
headers :: StrMap String
...
}
ajaxRequestDefaults :: String -> AjaxRequestThen a separate module could define combinators, such as:
GET :: AjaxRequest -> AjaxRequest
contentType :: MimeType -> AjaxRequest -> AjaxRequest
...
runAjax :: String -> (AjaxRequest -> AjaxRequest) -> Aff (ajax :: AJAX | e) AjaxResponse
runAjax url f = ajax (f (ajaxRequestDefaults url))So you'd write code like:
runAjax "http://foo.com" $ GET >>> contentType applicationJsonBut I'm sure there are better APIs. Let's discuss here if you have any ideas.
Metadata
Metadata
Assignees
Labels
type: enhancementA new feature or addition.A new feature or addition.