@@ -20,7 +20,6 @@ module Reflex.Dom.Widget.Basic
22 , widgetHold
22 , widgetHold
25 -- * Creating DOM Elements
24 -- * Creating DOM Elements
@@ -47,20 +46,14 @@ module Reflex.Dom.Widget.Basic
57 -- * Tables and Lists
49 -- * Tables and Lists
58 , tableDynAttr
50 , tableDynAttr
59 , tabDisplay
51 , tabDisplay
61 , HasAttributes (..)
53 , HasAttributes (..)
62− , module Reflex.Collection
63 , module Data.Map.Misc
54 , module Data.Map.Misc
55+ , module Reflex.Collection
56+ , module Reflex.Workflow
66import Reflex.Class
59import Reflex.Class
@@ -68,7 +61,10 @@ import Reflex.Collection
68import Reflex.Dom.Builder.Class
61import Reflex.Dom.Builder.Class
69import Reflex.Dom.Class
62import Reflex.Dom.Class
70import Reflex.Dynamic
63import Reflex.Dynamic
65+import Reflex.NotReady.Class
71import Reflex.PostBuild.Class
66import Reflex.PostBuild.Class
67+import Reflex.Workflow
73import Control.Arrow
69import Control.Arrow
74import Control.Lens hiding (children, element)
70import Control.Lens hiding (children, element)
@@ -89,9 +85,6 @@ import Data.These
89import Data.Traversable
85import Data.Traversable
90import Prelude hiding (mapM, mapM_, sequence, sequence_)
86import Prelude hiding (mapM, mapM_, sequence, sequence_)
92−widgetHoldInternal :: forall t m a b. DomBuilder t m => m a -> Event t (m b) -> m (a, Event t b)
93−widgetHoldInternal = runWithReplace
95-- | 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.
88-- | 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.
96-- 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.
89-- 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.
97-- No empty pieces will be included in the output.
90-- No empty pieces will be included in the output.
@@ -137,25 +130,13 @@ button t = do
137-- The returned Event of widget results occurs when the Dynamic does.
130-- The returned Event of widget results occurs when the Dynamic does.
138-- 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').
131-- 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').
139dyn :: (DomBuilder t m, PostBuild t m) => Dynamic t (m a) -> m (Event t a)
132dyn :: (DomBuilder t m, PostBuild t m) => Dynamic t (m a) -> m (Event t a)
140−dyn child = do
133+dyn = networkView
141− postBuild <- getPostBuild
142− let newChild = leftmost [updated child, tagCheap (current child) postBuild]
143− snd <$> widgetHoldInternal notReady newChild
145-- | Given an initial widget and an Event of widget-creating actions, create a widget that is recreated whenever the Event fires.
135-- | Given an initial widget and an Event of widget-creating actions, create a widget that is recreated whenever the Event fires.
146-- The returned Dynamic of widget results occurs when the Event does.
136-- The returned Dynamic of widget results occurs when the Event does.
147-- Note: Often, the type 'a' is an Event, in which case the return value is a Dynamic-of-Events that would typically be flattened.
137-- Note: Often, the type 'a' is an Event, in which case the return value is a Dynamic-of-Events that would typically be flattened.
148widgetHold :: (DomBuilder t m, MonadHold t m) => m a -> Event t (m a) -> m (Dynamic t a)
138widgetHold :: (DomBuilder t m, MonadHold t m) => m a -> Event t (m a) -> m (Dynamic t a)
149−widgetHold child0 newChild = do
139+widgetHold = networkHold
150− (result0, newResult) <- widgetHoldInternal child0 newChild
151− holdDyn result0 newResult
153−-- | Render a placeholder widget to be shown while another widget is not yet
155−untilReady :: (DomBuilder t m, PostBuild t m) => m a -> m b -> m (a, Event t b)
157− postBuild <- getPostBuild
158− runWithReplace a $ b <$ postBuild
160-- | Create a DOM element
141-- | Create a DOM element
161-- > el "div" (text "Hello World")
142-- > el "div" (text "Hello World")
@@ -295,25 +276,6 @@ dtdd h w = do
295blank :: forall m. Monad m => m ()
276blank :: forall m. Monad m => m ()
296blank = return ()
277blank = return ()
298−newtype Workflow t m a = Workflow { unWorkflow :: m (a, Event t (Workflow t m a)) }
300−workflow :: forall t m a. (DomBuilder t m, MonadFix m, MonadHold t m) => Workflow t m a -> m (Dynamic t a)
302− rec eResult <- widgetHold (unWorkflow w0) $ fmap unWorkflow $ switch $ snd <$> current eResult
303− return $ fmap fst eResult
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)
307− rec eResult <- dyn . fmap unWorkflow =<< holdDyn w0 eReplace
308− eReplace <- fmap switch $ hold never $ fmap snd eResult
309− return $ fmap fst eResult
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)
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)
317-- | A widget to display a table with static columns and dynamic rows.
279-- | A widget to display a table with static columns and dynamic rows.
318tableDynAttr :: forall t m r k v. (Ord k, DomBuilder t m, MonadHold t m, PostBuild t m, MonadFix m)
280tableDynAttr :: forall t m r k v. (Ord k, DomBuilder t m, MonadHold t m, PostBuild t m, MonadFix m)
319 => Text -- ^ Class applied to <table> element
281 => Text -- ^ Class applied to <table> element