on develop help sign in
Merge develop into jsaddle
8c79ce6Hamish Mackenzie
reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs+2−2
@@ -31,7 +31,7 @@ import Reflex.TriggerEvent.Base hiding (askEvents)
31import Reflex.TriggerEvent.Class
31import Reflex.TriggerEvent.Class
32
32
33import Control.Concurrent.Chan
33import Control.Concurrent.Chan
34−import Control.Lens hiding (element)
34+import Control.Lens hiding (element, ix)
35import Control.Monad.Exception
35import Control.Monad.Exception
36import Control.Monad.Primitive
36import Control.Monad.Primitive
37import Control.Monad.Reader
37import Control.Monad.Reader
@@ -986,7 +986,7 @@ getTouchEvent = do
986 Nothing -> return []
986 Nothing -> return []
987 Just ts -> do
987 Just ts -> do
988 n <- TouchList.getLength ts
988 n <- TouchList.getLength ts
989− fmap catMaybes . forM [0 .. n - 1] $ \ix -> do
989+ fmap catMaybes . forM (takeWhile (< n) [0..]) $ \ix -> do
990 mt <- TouchList.item ts ix
990 mt <- TouchList.item ts ix
991 forM mt $ \t -> do
991 forM mt $ \t -> do
992 identifier <- Touch.getIdentifier t
992 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
211listWithKey vals mkChild = do
211listWithKey vals mkChild = do
212 postBuild <- getPostBuild
212 postBuild <- getPostBuild
213 let childValChangedSelector = fanMap $ updated vals
213 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
214 rec sentVals :: Dynamic t (Map k v) <- foldDyn applyMap Map.empty changeVals
221 rec sentVals :: Dynamic t (Map k v) <- foldDyn applyMap Map.empty changeVals
215 let changeVals :: Event t (Map k (Maybe v))
222 let changeVals :: Event t (Map k (Maybe v))
216− changeVals = attachWith diffMapNoEq (current sentVals) $ leftmost
223+ changeVals = attachWith diffOnlyKeyChanges (current sentVals) $ leftmost
217 [ updated vals
224 [ updated vals
218 , 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
225 , 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
219 ]
226 ]