reflex-gadt-api-0.1.0.0: Interact with a GADT API in your reflex-dom application.

Safe HaskellNone
LanguageHaskell2010

Reflex.Dom.GadtApi

Synopsis

Documentation

performXhrRequests :: forall t m api js. (Has FromJSON api, forall a. ToJSON (api a), Prerender js t m, Applicative m) => ApiEndpoint -> Event t (RequesterData api) -> m (Dynamic t (Event t (RequesterData (Either Text)))) Source #

Takes the output of a RequesterT widget and issues that output as API requests. The result of this function can be fed back into the requester as responses. For example:

rec (appResult, requests) <- runRequesterT myApplication $
      switchPromptlyDyn responses
    responses <- performXhrRequests myApiEndpoint requests

apiRequestXhr :: forall api m. (MonadIO m, HasJSContext m, MonadJSM m, Has FromJSON api, forall a. ToJSON (api a)) => ApiEndpoint -> RequesterData api -> m (RequesterData (Either Text)) Source #

Encodes an API request as JSON and issues an XhrRequest, and attempts to decode the response.