on develop help sign in
Hopefully fix the issue where withRenderHook doesn't apply to certain changes
3b102c3Ryan Trinkle
reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs+8−6
@@ -633,7 +633,7 @@ instance (Reflex t, MonadAdjust t m, MonadJSM m, MonadHold t m, MonadFix m, Prim
633 _ -> modifyIORef' parentUnreadyChildren succ
633 _ -> modifyIORef' parentUnreadyChildren succ
634 return result
634 return result
635 a'' <- numberOccurrences a'
635 a'' <- numberOccurrences a'
636− (result0, result') <- ImmediateDomBuilderT $ lift $ runWithReplace drawInitialChild $ ffor a'' $ \(cohortId, child) -> do
636+ (result0, child') <- ImmediateDomBuilderT $ lift $ runWithReplace drawInitialChild $ ffor a'' $ \(cohortId, child) -> do
637 df <- createDocumentFragmentUnchecked doc
637 df <- createDocumentFragmentUnchecked doc
638 unreadyChildren <- liftIO $ newIORef 0
638 unreadyChildren <- liftIO $ newIORef 0
639 let commitAction = do
639 let commitAction = do
@@ -648,11 +648,13 @@ instance (Reflex t, MonadAdjust t m, MonadJSM m, MonadHold t m, MonadFix m, Prim
648 , _immediateDomBuilderEnv_unreadyChildren = unreadyChildren
648 , _immediateDomBuilderEnv_unreadyChildren = unreadyChildren
649 , _immediateDomBuilderEnv_commitAction = commitAction
649 , _immediateDomBuilderEnv_commitAction = commitAction
650 }
650 }
651− liftIO (readIORef unreadyChildren) >>= \case
651+ uc <- liftIO $ readIORef unreadyChildren
652+ let commitActionToRunNow = if uc == 0
652− 0 -> liftJSM commitAction
653+ then Just commitAction
653− _ -> return () -- Whoever decrements it to 0 will handle it
654+ else Nothing -- A child will run it when unreadyChildren is decremented to 0
654− return result
655+ return (commitActionToRunNow, result)
656+ requestDomAction_ $ fmapMaybe fst child'
655− return (result0, result')
657+ return (result0, snd <$> child')
656 traverseDMapWithKeyWithAdjust = do
658 traverseDMapWithKeyWithAdjust = do
657 let updateChildUnreadiness (p :: PatchDMap k (Compose ((,,,) DOM.DocumentFragment DOM.Text (IORef (ChildReadyState k))) v')) old = do
659 let updateChildUnreadiness (p :: PatchDMap k (Compose ((,,,) DOM.DocumentFragment DOM.Text (IORef (ChildReadyState k))) v')) old = do
658 let new :: forall a. k a -> ComposeMaybe (Compose ((,,,) DOM.DocumentFragment DOM.Text (IORef (ChildReadyState k))) v') a -> IO (ComposeMaybe (Constant (IORef (ChildReadyState k))) a)
660 let new :: forall a. k a -> ComposeMaybe (Compose ((,,,) DOM.DocumentFragment DOM.Text (IORef (ChildReadyState k))) v') a -> IO (ComposeMaybe (Constant (IORef (ChildReadyState k))) a)