Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type ApiEndpoint = Text
- 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))))
- 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))
Documentation
type ApiEndpoint = Text Source #
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.