@@ -154,10 +154,7 @@ runWithReplaceEventWriterTWith :: forall m t w a b. (Reflex t, MonadHold t m, Se
154 -> EventWriterT t w m (a, Event t b)
154 -> EventWriterT t w m (a, Event t b)
155runWithReplaceEventWriterTWith f a0 a' = do
155runWithReplaceEventWriterTWith f a0 a' = do
156 (result0, result') <- f (runEventWriterT a0) $ fmapCheap runEventWriterT a'
156 (result0, result') <- f (runEventWriterT a0) $ fmapCheap runEventWriterT a'
157− request <- holdDyn (snd result0) $ fmapCheap snd result'
157+ tellEvent =<< switchHoldPromptOnly (snd result0) (fmapCheap snd result')
158− -- We add these two separately to take advantage of the free merge being done later. The coincidence case must come first so that it has precedence if both fire simultaneously. (Really, we should probably block the 'switch' whenever 'updated' fires, but switchPromptlyDyn has the same issue.)
159− tellEvent $ coincidence $ updated request
160− tellEvent $ switch $ current request
161 return (fst result0, fmapCheap fst result')
158 return (fst result0, fmapCheap fst result')
163-- | Like 'runWithReplaceEventWriterTWith', but for 'sequenceIntMapWithAdjust'.
160-- | Like 'runWithReplaceEventWriterTWith', but for 'sequenceIntMapWithAdjust'.
@@ -219,6 +216,7 @@ sequenceDMapWithAdjustEventWriterTWith base mapPatch weakenPatchWith patchNewEle
219tellEventsPromptly
216tellEventsPromptly
220 :: ( Foldable f
217 :: ( Foldable f
221 , Reflex t
218 , Reflex t
222 , EventWriter t w m
220 , EventWriter t w m
224 => Event t a
222 => Event t a
@@ -226,11 +224,10 @@ tellEventsPromptly
226 -> Event t (f w)
224 -> Event t (f w)
228tellEventsPromptly requests' patchNewElements mergedChildRequestMap = do
226tellEventsPromptly requests' patchNewElements mergedChildRequestMap = do
229− -- We add these two separately to take advantage of the free merge being done later. The coincidence case must come first so that it has precedence if both fire simultaneously. (Really, we should probably block the 'switch' whenever 'updated' fires, but switchPromptlyDyn has the same issue.)
230− tellEvent $ coincidence $ fmapCheap (mconcat . patchNewElements) requests' --TODO: Create a mergeIncrementalPromptly, and use that to eliminate this 'coincidence'
231− tellEvent $ fforMaybeCheap mergedChildRequestMap $ \m -> case toList m of
227+ let patch0 = fforMaybeCheap mergedChildRequestMap $ \m -> case toList m of
232− [] -> Nothing
228+ [] -> Nothing
233− h : t -> Just $ sconcat $ h :| t
229+ h : t -> Just $ sconcat $ h :| t
230+ tellEvent =<< switchHoldPromptOnly patch0 (fmapCheap (mconcat . patchNewElements) requests')
235instance PerformEvent t m => PerformEvent t (EventWriterT t w m) where
232instance PerformEvent t m => PerformEvent t (EventWriterT t w m) where
236 type Performable (EventWriterT t w m) = Performable m
233 type Performable (EventWriterT t w m) = Performable m