on develop help sign in
Merge develop into jsaddle
commit8c79ce6f80f5d0e306cb4c5f3422bc4475655edd authorHamish Mackenzie <Hamish.K.Mackenzie@googlemail.com> dateTue 7 Feb 2017, 20:50 (10 years ago) parent5793a2f9626d64
2 files changed+10−3
reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs+2−2 reflex-dom-core/src/Reflex/Dom/Widget/Basic.hs+8−1
reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs+2−2
@@ -31,7 +31,7 @@ import Reflex.TriggerEvent.Base hiding (askEvents)
3131import Reflex.TriggerEvent.Class
3232
3333import Control.Concurrent.Chan
34−import Control.Lens hiding (element)
34+import Control.Lens hiding (element, ix)
3535import Control.Monad.Exception
3636import Control.Monad.Primitive
3737import Control.Monad.Reader
@@ -986,7 +986,7 @@ getTouchEvent = do
986986 Nothing -> return []
987987 Just ts -> do
988988 n <- TouchList.getLength ts
989− fmap catMaybes . forM [0 .. n - 1] $ \ix -> do
989+ fmap catMaybes . forM (takeWhile (< n) [0..]) $ \ix -> do
990990 mt <- TouchList.item ts ix
991991 forM mt $ \t -> do
992992 identifier <- Touch.getIdentifier t
reflex-dom-core/src/Reflex/Dom/Widget/Basic.hs+8−1
@@ -211,9 +211,16 @@ listWithKey :: forall t k v m a. (Ord k, DomBuilder t m, PostBuild t m, MonadFix
211211listWithKey vals mkChild = do
212212 postBuild <- getPostBuild
213213 let childValChangedSelector = fanMap $ updated vals
214+ -- We keep track of changes to children values in the mkChild function we pass to listHoldWithKey
215+ -- The other changes we need to keep track of are child insertions and deletions. diffOnlyKeyChanges
216+ -- keeps track of insertions and deletions but ignores value changes, since they're already accounted for.
217+ diffOnlyKeyChanges olds news = flip Map.mapMaybe (align olds news) $ \case
218+ This _ -> Just Nothing
219+ These _ _ -> Nothing
220+ That new -> Just $ Just new
214221 rec sentVals :: Dynamic t (Map k v) <- foldDyn applyMap Map.empty changeVals
215222 let changeVals :: Event t (Map k (Maybe v))
216− changeVals = attachWith diffMapNoEq (current sentVals) $ leftmost
223+ changeVals = attachWith diffOnlyKeyChanges (current sentVals) $ leftmost
217224 [ updated vals
218225 , 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
219226 ]