@@ -46,6 +46,23 @@ module Reflex.Dom.Xhr
47 -- 3. Consume the resulting stream of 'XhrResponse' events,
47 -- 3. Consume the resulting stream of 'XhrResponse' events,
48 -- parsing the body of the response however appropriate.
48 -- parsing the body of the response however appropriate.
50+ -- Here is an example of calling a search API whenever the user
51+ -- types in a text input field and printing the result on the page:
54+ -- url query = "http://example.com/search?query=" <> query
56+ -- search queries = do
57+ -- responses <- performRequestAsync $ toRequest <$> queries
58+ -- return $ view xhrResponse_responseText <$> responses
59+ -- where toRequest query = XhrRequest "GET" (url query) def
61+ -- main = mainWidget $ do
62+ -- queries <- textInput def
63+ -- results <- search queries
64+ -- dynText $ holdDyn "No results." results
50 -- ** XHR Requests
67 -- ** XHR Requests
51 , XhrRequest (..)
68 , XhrRequest (..)