on develop help sign in
Fixed the request example in the General API section.
commit8412fb18ec5f2f91fdcb614feaea5f65d5d19179 authorTikhon Jelvis <tikhon.jelvis@target.com> dateFri 27 Jan 2017, 14:40 (10 years ago) parentf492849
1 file changed+7−3
src/Reflex/Dom/Xhr.hs+7−3
src/Reflex/Dom/Xhr.hs+7−3
@@ -45,7 +45,9 @@ module Reflex.Dom.Xhr
4545 -- for performing requests like 'performRequestAsync'.
4646 --
4747 -- 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.
4951 --
5052 -- Here is an example of calling a search API whenever the user
5153 -- types in a text input field and printing the result on the page:
@@ -59,9 +61,11 @@ module Reflex.Dom.Xhr
5961 -- where toRequest query = XhrRequest "GET" (url query) def
6062 --
6163 -- main = mainWidget $ do
62− -- queries <- textInput def
64+ -- input <- textInput def
65+ -- let queries = updated $ input ^. textInput_value
6366 -- results <- search queries
64− -- dynText $ holdDyn "No results." results
67+ -- asText <- holdDyn "No results." $ pack . show <$> results
68+ -- dynText asText
6569 -- @
6670
6771 -- ** XHR Requests