aboutsummaryrefslogtreecommitdiff
path: root/client/src/Util
diff options
context:
space:
mode:
authorJoris2019-10-20 22:08:31 +0200
committerJoris2019-10-20 22:08:31 +0200
commit33e78f2ebbf5bf7b40e7aa732cc7c019f6df3f12 (patch)
treebc325950963bcb5c27e1aaba2a4ee7e092efbcd4 /client/src/Util
parent602c52acfcfa494b07fec05c20b317b60ea8a6f3 (diff)
Simplify page initialization
Diffstat (limited to 'client/src/Util')
-rw-r--r--client/src/Util/Ajax.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/client/src/Util/Ajax.hs b/client/src/Util/Ajax.hs
index 9cd5105..47f4f3c 100644
--- a/client/src/Util/Ajax.hs
+++ b/client/src/Util/Ajax.hs
@@ -1,5 +1,6 @@
module Util.Ajax
- ( get
+ ( getNow
+ , get
, post
, put
, delete
@@ -21,6 +22,14 @@ import Reflex.Dom (Dynamic, Event, IsXhrPayload,
XhrResponseHeaders (..))
import qualified Reflex.Dom as R
+import Loadable (Loadable)
+import qualified Loadable
+
+getNow :: forall t m a. (MonadWidget t m, FromJSON a) => Text -> m (Dynamic t (Loadable a))
+getNow url = do
+ postBuild <- R.getPostBuild
+ get (R.tag (R.constant url) postBuild) >>= Loadable.fromEvent
+
get
:: forall t m a. (MonadWidget t m, FromJSON a)
=> Event t Text