@@ -20,7 +20,6 @@ module Reflex.Dom.Widget.Basic
2020 , button
2121 , dyn
2222 , widgetHold
23− , untilReady
2423
2524 -- * Creating DOM Elements
2625 , el
@@ -47,20 +46,14 @@ module Reflex.Dom.Widget.Basic
4746 , dtdd
4847 , blank
4948
50− -- * Workflows
51− , Workflow (..)
52− , workflow
53− , workflowView
54− , mapWorkflow
55− , mapWorkflowCheap
56−
5749 -- * Tables and Lists
5850 , tableDynAttr
5951 , tabDisplay
6052
6153 , HasAttributes (..)
62− , module Reflex.Collection
6354 , module Data.Map.Misc
55+ , module Reflex.Collection
56+ , module Reflex.Workflow
6457 ) where
6558
6659import Reflex.Class
@@ -68,7 +61,10 @@ import Reflex.Collection
6861import Reflex.Dom.Builder.Class
6962import Reflex.Dom.Class
7063import Reflex.Dynamic
64+import Reflex.Network
65+import Reflex.NotReady.Class
7166import Reflex.PostBuild.Class
67+import Reflex.Workflow
7268
7369import Control.Arrow
7470import Control.Lens hiding (children, element)
@@ -89,9 +85,6 @@ import Data.These
8985import Data.Traversable
9086import Prelude hiding (mapM, mapM_, sequence, sequence_)
9187
92−widgetHoldInternal :: forall t m a b. DomBuilder t m => m a -> Event t (m b) -> m (a, Event t b)
93−widgetHoldInternal = runWithReplace
94−
9588-- | Breaks the given Map into pieces based on the given Set. Each piece will contain only keys that are less than the key of the piece, and greater than or equal to the key of the piece with the next-smaller key. There will be one additional piece containing all keys from the original Map that are larger or equal to the largest key in the Set.
9689-- Either k () is used instead of Maybe k so that the resulting map of pieces is sorted so that the additional piece has the largest key.
9790-- No empty pieces will be included in the output.
@@ -137,25 +130,13 @@ button t = do
137130-- The returned Event of widget results occurs when the Dynamic does.
138131-- Note: Often, the type 'a' is an Event, in which case the return value is an Event-of-Events that would typically be flattened (via 'switchPromptly').
139132dyn :: (DomBuilder t m, PostBuild t m) => Dynamic t (m a) -> m (Event t a)
140−dyn child = do
141− postBuild <- getPostBuild
142− let newChild = leftmost [updated child, tagCheap (current child) postBuild]
143− snd <$> widgetHoldInternal notReady newChild
133+dyn = networkView
144134
145135-- | Given an initial widget and an Event of widget-creating actions, create a widget that is recreated whenever the Event fires.
146136-- The returned Dynamic of widget results occurs when the Event does.
147137-- Note: Often, the type 'a' is an Event, in which case the return value is a Dynamic-of-Events that would typically be flattened.
148138widgetHold :: (DomBuilder t m, MonadHold t m) => m a -> Event t (m a) -> m (Dynamic t a)
149−widgetHold child0 newChild = do
150− (result0, newResult) <- widgetHoldInternal child0 newChild
151− holdDyn result0 newResult
152−
153−-- | Render a placeholder widget to be shown while another widget is not yet
154−-- done rendering
155−untilReady :: (DomBuilder t m, PostBuild t m) => m a -> m b -> m (a, Event t b)
156−untilReady a b = do
157− postBuild <- getPostBuild
158− runWithReplace a $ b <$ postBuild
139+widgetHold = networkHold
159140
160141-- | Create a DOM element
161142-- > el "div" (text "Hello World")
@@ -295,25 +276,6 @@ dtdd h w = do
295276blank :: forall m. Monad m => m ()
296277blank = return ()
297278
298−newtype Workflow t m a = Workflow { unWorkflow :: m (a, Event t (Workflow t m a)) }
299−
300−workflow :: forall t m a. (DomBuilder t m, MonadFix m, MonadHold t m) => Workflow t m a -> m (Dynamic t a)
301−workflow w0 = do
302− rec eResult <- widgetHold (unWorkflow w0) $ fmap unWorkflow $ switch $ snd <$> current eResult
303− return $ fmap fst eResult
304−
305−workflowView :: forall t m a. (DomBuilder t m, MonadFix m, MonadHold t m, PostBuild t m) => Workflow t m a -> m (Event t a)
306−workflowView w0 = do
307− rec eResult <- dyn . fmap unWorkflow =<< holdDyn w0 eReplace
308− eReplace <- fmap switch $ hold never $ fmap snd eResult
309− return $ fmap fst eResult
310−
311−mapWorkflow :: (DomBuilder t m) => (a -> b) -> Workflow t m a -> Workflow t m b
312−mapWorkflow f (Workflow x) = Workflow (fmap (f *** fmap (mapWorkflow f)) x)
313−
314−mapWorkflowCheap :: (DomBuilder t m) => (a -> b) -> Workflow t m a -> Workflow t m b
315−mapWorkflowCheap f (Workflow x) = Workflow (fmap (f *** fmapCheap (mapWorkflowCheap f)) x)
316−
317279-- | A widget to display a table with static columns and dynamic rows.
318280tableDynAttr :: forall t m r k v. (Ord k, DomBuilder t m, MonadHold t m, PostBuild t m, MonadFix m)
319281 => Text -- ^ Class applied to <table> element