@@ -79,7 +79,7 @@ module Reflex.Dom.Widget.Basic
79 , HasAttributes (..)
79 , HasAttributes (..)
82−import Reflex.Class as Reflex
82+import Reflex.Class
83import Reflex.Dom.Builder.Class
83import Reflex.Dom.Builder.Class
84import Reflex.Dom.Class
84import Reflex.Dom.Class
85import Reflex.Dom.Internal.Foreign ()
85import Reflex.Dom.Internal.Foreign ()
@@ -228,14 +228,15 @@ applyMapKeysSet patch old = Map.keysSet insertions `Set.union` (old `Set.differe
228listWithKey :: forall t k v m a. (Ord k, DomBuilder t m, PostBuild t m, MonadFix m, MonadHold t m) => Dynamic t (Map k v) -> (k -> Dynamic t v -> m a) -> m (Dynamic t (Map k a))
228listWithKey :: forall t k v m a. (Ord k, DomBuilder t m, PostBuild t m, MonadFix m, MonadHold t m) => Dynamic t (Map k v) -> (k -> Dynamic t v -> m a) -> m (Dynamic t (Map k a))
229listWithKey vals mkChild = do
229listWithKey vals mkChild = do
230 postBuild <- getPostBuild
230 postBuild <- getPostBuild
231+ let childValChangedSelector = fanMap $ updated vals
231 rec sentVals :: Dynamic t (Map k v) <- foldDyn applyMap Map.empty changeVals
232 rec sentVals :: Dynamic t (Map k v) <- foldDyn applyMap Map.empty changeVals
232 let changeVals :: Event t (Map k (Maybe v))
233 let changeVals :: Event t (Map k (Maybe v))
233 changeVals = attachWith diffMapNoEq (current sentVals) $ leftmost
234 changeVals = attachWith diffMapNoEq (current sentVals) $ leftmost
234 [ updated vals
235 [ updated vals
235 , tag (current vals) postBuild --TODO: This should probably be added to the attachWith, not to the updated; if we were using diffMap instead of diffMapNoEq, I think it might not work
236 , tag (current vals) postBuild --TODO: This should probably be added to the attachWith, not to the updated; if we were using diffMap instead of diffMapNoEq, I think it might not work
237− listWithKeyShallowDiff Map.empty changeVals $ \k v0 dv -> do
238+ listHoldWithKey Map.empty changeVals $ \k v ->
238− mkChild k =<< holdDyn v0 dv
239+ mkChild k =<< holdDyn v (select childValChangedSelector $ Const2 k)
240{-# DEPRECATED listWithKey' "listWithKey' has been renamed to listWithKeyShallowDiff; also, its behavior has changed to fix a bug where children were always rebuilt (never updated)" #-}
241{-# DEPRECATED listWithKey' "listWithKey' has been renamed to listWithKeyShallowDiff; also, its behavior has changed to fix a bug where children were always rebuilt (never updated)" #-}
241listWithKey' :: (Ord k, DomBuilder t m, MonadFix m, MonadHold t m) => Map k v -> Event t (Map k (Maybe v)) -> (k -> v -> Event t v -> m a) -> m (Dynamic t (Map k a))
242listWithKey' :: (Ord k, DomBuilder t m, MonadFix m, MonadHold t m) => Map k v -> Event t (Map k (Maybe v)) -> (k -> v -> Event t v -> m a) -> m (Dynamic t (Map k a))
@@ -250,7 +251,7 @@ listWithKeyShallowDiff initialVals valsChanged mkChild = do
250 Nothing -> Just Nothing -- Even if we let a Nothing through when the element doesn't already exist, this doesn't cause a problem because it is ignored
251 Nothing -> Just Nothing -- Even if we let a Nothing through when the element doesn't already exist, this doesn't cause a problem because it is ignored
251 Just _ -> Nothing -- We don't want to let spurious re-creations of items through
252 Just _ -> Nothing -- We don't want to let spurious re-creations of items through
252 listHoldWithKey initialVals (attachWith (flip (Map.differenceWith relevantPatch)) (current sentVals) valsChanged) $ \k v ->
253 listHoldWithKey initialVals (attachWith (flip (Map.differenceWith relevantPatch)) (current sentVals) valsChanged) $ \k v ->
253− mkChild k v $ Reflex.select childValChangedSelector $ Const2 k
254+ mkChild k v $ select childValChangedSelector $ Const2 k
255--TODO: Something better than Dynamic t (Map k v) - we want something where the Events carry diffs, not the whole value
256--TODO: Something better than Dynamic t (Map k v) - we want something where the Events carry diffs, not the whole value
256-- | Create a dynamically-changing set of Event-valued widgets.
257-- | Create a dynamically-changing set of Event-valued widgets.