@@ -45,7 +45,9 @@ module Reflex.Dom.Xhr
45 -- for performing requests like 'performRequestAsync'.
45 -- for performing requests like 'performRequestAsync'.
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. A really
49+ -- common pattern is turning the 'Event' into a 'Dynamic' with
50+ -- 'holdDyn' or a related function.
50 -- Here is an example of calling a search API whenever the user
52 -- 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:
53 -- types in a text input field and printing the result on the page:
@@ -59,9 +61,11 @@ module Reflex.Dom.Xhr
59 -- where toRequest query = XhrRequest "GET" (url query) def
61 -- where toRequest query = XhrRequest "GET" (url query) def
61 -- main = mainWidget $ do
63 -- main = mainWidget $ do
62− -- queries <- textInput def
64+ -- input <- textInput def
65+ -- let queries = updated $ input ^. textInput_value
63 -- results <- search queries
66 -- results <- search queries
64− -- dynText $ holdDyn "No results." results
67+ -- asText <- holdDyn "No results." $ pack . show <$> results
67 -- ** XHR Requests
71 -- ** XHR Requests