on master help sign in
Merge master
commitdd16ebb71eba1bbafe4c20fb9fbfe2fb525ed1cb authorGreg Hale <imalsogreg@gmail.com> dateSat 3 Feb 2018, 10:56 (9 years ago) parentd4dabac6593c1c
6 files changed+12−12
README.md+3−3 servant-reflex.cabal+1−1 src/Servant/Common/BaseUrl.hs+1−1 src/Servant/Common/Req.hs+5−5 src/Servant/Reflex.hs+1−1 src/Servant/Reflex/Multi.hs+1−1
README.md+3−3
@@ -37,7 +37,7 @@ type API = "getint" :> Get '[JSON] Int
3737 (constDyn (BasePath "/"))
3838```
3939
40−These client functions are computed from your API type. They manage serialization, XhrRequest generation, and deserialization for you. `a` parameters used in URL captures become `Dynamic t (Either Text a)` parameters in the client functions. 'QueryFlag', 'QueryParams' and 'QueryParam' API parameters map to 'Dynamic t Bool', 'Dynamic t [a]' and 'Dynamic t (QParam a)' respectively. These parameters to the client function are wrapped with failure possibility to allow you to indicate at any time whether input validation for that parameter has failed and no valid XHR request can be generated. The final parameter is a trigger event for the XHR request. The return value `Event t (ReqResult a)` contains responses from the API server.
40+These client functions are computed from your API type. They manage serialization, `XhrRequest` generation, and deserialization for you. `a` parameters used in URL captures become `Dynamic t (Either Text a)` parameters in the client functions. `QueryFlag`, `QueryParams` and `QueryParam` API parameters map to `Dynamic t Bool`, `Dynamic t [a]` and `Dynamic t (QParam a)` respectively. These parameters to the client function are wrapped with failure possibility to allow you to indicate at any time whether input validation for that parameter has failed and no valid XHR request can be generated. The final parameter is a trigger event for the XHR request. The return value `Event t (ReqResult a)` contains responses from the API server.
4141
4242```haskell
4343 -- No need to write these functions. servant-reflex creates them for you!
@@ -173,7 +173,7 @@ So far we have used an `Event t ()` to trigger sending a request. If we choose e
173173
174174## Simultaneous requests
175175
176−'Servant.Reflex.Multi' provides an alternative client-generation function called 'clientA' (client applicative). Choose a container type that has both `Applicative` and `Traversable` instances, and pass it to `clientA` through another 'Proxy'. Our `sayHi` client function will then have this type:
176+`Servant.Reflex.Multi` provides an alternative client-generation function called `clientA` (client applicative). Choose a container type that has both `Applicative` and `Traversable` instances, and pass it to `clientA` through another `Proxy`. Our `sayHi` client function will then have this type:
177177
178178```haskell
179179sayHi
@@ -184,4 +184,4 @@ sayHi
184184 -> m (Event t (f (ReqResult tag Text)))
185185```
186186
187−The dynamic params are each wrapped in `f`. For every firing of the trigger event `tag`, all of these parameters will be combined according to `f`'s applicative instance (when `f` is `[]`, you will get all combinations of all parameters taken together as a request; when `f` is 'ZipList', the Nth elemens of each parameters list will be taken together as a request). Using this interface, you can trigger many XHR's from a single event occurence, and expect the responses to be structured the same way as the requests.
187+The dynamic params are each wrapped in `f`. For every firing of the trigger event `tag`, all of these parameters will be combined according to `f`'s `Applicative` instance (when `f` is `[]`, you will get all combinations of all parameters taken together as a request; when `f` is `ZipList`, the Nth elemens of each parameters list will be taken together as a request). Using this interface, you can trigger many XHR's from a single event occurence, and expect the responses to be structured the same way as the requests.
servant-reflex.cabal+1−1
@@ -40,7 +40,7 @@ library
4040 mtl >= 2.2.1 && < 2.3,
4141 network-uri >= 2.6 && < 2.7,
4242 reflex >= 0.5 && < 0.6,
43− reflex-dom == 0.4 && < 0.5,
43+ reflex-dom-core == 0.4 && < 0.5,
4444 safe >= 0.3.9 && < 0.4,
4545 servant >= 0.8 && < 0.12,
4646 servant-auth >= 0.2.1 && < 0.4,
src/Servant/Common/BaseUrl.hs+1−1
@@ -28,7 +28,7 @@ import qualified Data.Text as T
2828import GHC.Generics
2929import Language.Javascript.JSaddle.Monad (MonadJSM)
3030import Reflex
31−import Reflex.Dom
31+import Reflex.Dom.Core
3232import Text.Read
3333
3434
src/Servant/Common/Req.hs+5−5
@@ -33,11 +33,11 @@ import qualified Data.Text as T
3333import qualified Data.Text.Lazy as TL
3434import qualified Data.Text.Encoding as T
3535import Data.Traversable (forM)
36−import Language.Javascript.JSaddle.Monad (JSM, MonadJSM)
36+import Language.Javascript.JSaddle.Monad (JSM, MonadJSM, liftJSM)
3737import qualified Language.Javascript.JSaddle as JS
3838import qualified Data.JSString.Text as JS (lazyTextFromJSString)
3939import qualified Network.URI as N
40−import Reflex.Dom hiding (tag)
40+import Reflex.Dom.Core hiding (tag)
4141import Servant.Common.BaseUrl (BaseUrl, showBaseUrl,
4242 SupportsServantReflex)
4343import Servant.API.ContentTypes ( NoContent(..), Accept, JSON
@@ -63,7 +63,7 @@ data ReqResult tag a
6363 deriving (Functor)
6464
6565data ClientOptions = ClientOptions
66− { optsRequestFixup :: forall a. Show a => XhrRequest a -> IO (XhrRequest a)
66+ { optsRequestFixup :: forall a. Show a => XhrRequest a -> JSM (XhrRequest a)
6767 -- ^ Aribtrarily modify requests just before they are sent.
6868 -- Warning: This escape hatch opens the possibility for your
6969 -- requests to diverge from what the server expects, when the
@@ -319,7 +319,7 @@ performSomeRequestsAsync opts =
319319-- | A modified version or Reflex.Dom.Xhr.performRequestsAsync
320320-- that accepts 'f (Either e (XhrRequestb))' events
321321performSomeRequestsAsync'
322− :: (MonadIO (Performable m), PerformEvent t m, TriggerEvent t m, Traversable f, Show b)
322+ :: (MonadJSM (Performable m), PerformEvent t m, TriggerEvent t m, Traversable f, Show b)
323323 => ClientOptions
324324 -> (XhrRequest b -> (a -> JSM ()) -> Performable m XMLHttpRequest)
325325 -> Event t (Performable m (f (Either Text (XhrRequest b)))) -> m (Event t (f (Either Text a)))
@@ -331,7 +331,7 @@ performSomeRequestsAsync' opts newXhr req = performEventAsync $ ffor req $ \hrs
331331 return resp
332332 Right r' -> do
333333 resp <- liftIO newEmptyMVar
334− r'' <- liftIO $ (optsRequestFixup opts) r'
334+ r'' <- liftJSM $ (optsRequestFixup opts) r'
335335 _ <- newXhr r'' $ liftIO . putMVar resp . Right
336336 return resp
337337 _ <- liftIO $ forkIO $ cb =<< forM resps takeMVar
src/Servant/Reflex.hs+1−1
@@ -58,7 +58,7 @@ import Servant.API ((:<|>)(..),(:>), BasicAuth,
5858 ToHttpApiData(..), Vault, Verb)
5959import qualified Servant.Auth as Auth
6060
61−import Reflex.Dom (Dynamic, Event, Reflex,
61+import Reflex.Dom.Core (Dynamic, Event, Reflex,
6262 XhrRequest(..),
6363 XhrResponseHeaders(..),
6464 XhrResponse(..), attachPromptlyDynWith, constDyn, ffor, fmapMaybe,
src/Servant/Reflex/Multi.hs+1−1
@@ -55,7 +55,7 @@ import Servant.API ((:<|>) (..), (:>), BasicAuth,
5555 ReqBody, ToHttpApiData (..), Vault,
5656 Verb, contentType)
5757
58−import Reflex.Dom (Dynamic, Event, Reflex,
58+import Reflex.Dom.Core (Dynamic, Event, Reflex,
5959 XhrRequest (..),
6060 XhrResponseHeaders (..),
6161 attachPromptlyDynWith, constDyn)