reflex-dom-contrib-0.4.1: A playground for experimenting with infrastructure and common code for reflex applications

Safe HaskellNone
LanguageHaskell2010

Reflex.Dom.Contrib.Xhr

Description

Convenience functions for dealing with XMLHttpRequest.

Synopsis

Documentation

formEncode :: Map String ByteString -> String Source

URL encodes a map of key-value pairs.

formEncodeJSON :: ToJSON a => a -> String Source

Form encodes a JSON object.

toPost Source

Arguments

:: String

URL

-> String

The post data

-> XhrRequest 

Convenience function for constructing a POST request.

performAJAX Source

Arguments

:: MonadWidget t m 
=> (a -> XhrRequest)

Function to build the request

-> (XhrResponse -> b)

Function to parse the response

-> Event t a 
-> m (Event t (a, b)) 

This is the foundational primitive for the XHR API because it gives you full control over request generation and response parsing and also allows you to match things that generated the request with their corresponding responses.

performJsonAjax Source

Arguments

:: (MonadWidget t m, ToJSON a, FromJSON b) 
=> Event t (String, a)

Event with a URL and a JSON object to be sent

-> m (Event t (a, Maybe b)) 

Performs an async XHR taking a JSON object as input and another JSON object as output.