on develop help sign in
add selectViewListWithKey
commited50ec601b8b52365725af84d9ed95de7afad9a1 authorDaniel Haraj <daniel.haraj@skedge.me> dateMon 9 Nov 2015, 20:26 (11 years ago) parent92746fb
1 file changed+11−4
src/Reflex/Dom/Widget/Basic.hs+11−4
src/Reflex/Dom/Widget/Basic.hs+11−4
@@ -277,19 +277,26 @@ listViewWithKey' :: (Ord k, MonadWidget t m) => Dynamic t (Map k v) -> (k -> Dyn
277277listViewWithKey' vals mkChild = liftM current $ listWithKey vals mkChild
278278
279279-- | Create a dynamically-changing set of widgets, one of which is selected at any time.
280−selectViewListWithKey_ :: forall t m k v a. (MonadWidget t m, Ord k)
280+selectViewListWithKey :: forall t m k v a. (MonadWidget t m, Ord k)
281281 => Dynamic t k -- ^ Current selection key
282282 -> Dynamic t (Map k v) -- ^ Dynamic key/value map
283283 -> (k -> Dynamic t v -> Dynamic t Bool -> m (Event t a)) -- ^ Function to create a widget for a given key from Dynamic value and Dynamic Bool indicating if this widget is currently selected
284− -> m (Event t k) -- ^ Event that fires when any child's return Event fires. Contains key of an arbitrary firing widget.
285−selectViewListWithKey_ selection vals mkChild = do
284+ -> m (Event t (k, a)) -- ^ Event that fires when any child's return Event fires. Contains key of an arbitrary firing widget.
285+selectViewListWithKey selection vals mkChild = do
286286 let selectionDemux = demux selection -- For good performance, this value must be shared across all children
287287 selectChild <- listWithKey vals $ \k v -> do
288288 selected <- getDemuxed selectionDemux k
289289 selectSelf <- mkChild k v selected
290− return $ fmap (const k) selectSelf
290+ return $ fmap ((,) k) selectSelf
291291 liftM switchPromptlyDyn $ mapDyn (leftmost . Map.elems) selectChild
292292
293+selectViewListWithKey_ :: forall t m k v a. (MonadWidget t m, Ord k)
294+ => Dynamic t k -- ^ Current selection key
295+ -> Dynamic t (Map k v) -- ^ Dynamic key/value map
296+ -> (k -> Dynamic t v -> Dynamic t Bool -> m (Event t a)) -- ^ Function to create a widget for a given key from Dynamic value and Dynamic Bool indicating if this widget is currently selected
297+ -> m (Event t k) -- ^ Event that fires when any child's return Event fires. Contains key of an arbitrary firing widget.
298+selectViewListWithKey_ selection vals mkChild = liftM (fmap fst) $ selectViewListWithKey selection vals mkChild
299+
293300--------------------------------------------------------------------------------
294301-- Basic DOM manipulation helpers
295302--------------------------------------------------------------------------------