on develop help sign in
Fix #72

In PostBuildT's placeholder implementation, don't delete the childPostBuild event until after the placeholder has been destroyed

commitfa282cf85178a14aeb5f3cb70f8a8591950e5898 authorRyan Trinkle <ryan.trinkle@gmail.com> dateSat 16 Jul 2016, 15:22 (10 years ago) parentbe94e12
3 files changed+3−3
src/Reflex/Dom/Builder/Class.hs+1−1 src/Reflex/Dom/PostBuild/Class.hs+1−1 src/Reflex/Dom/Widget/Basic.hs+1−1
src/Reflex/Dom/Builder/Class.hs+1−1
@@ -135,7 +135,7 @@ instance Reflex t => Default (PlaceholderConfig above t m) where
135135
136136data Placeholder above t
137137 = Placeholder { _placeholder_insertedAbove :: Event t above
138− , _placeholder_deleted :: Event t ()
138+ , _placeholder_deletedSelf :: Event t ()
139139 }
140140
141141data InputElementConfig er t m
src/Reflex/Dom/PostBuild/Class.hs+1−1
@@ -48,7 +48,7 @@ instance (DomBuilder t m, PerformEvent t m, MonadFix m, MonadHold t m) => DomBui
4848 element t cfg child = liftWith $ \run -> element t (liftPostBuildTElementConfig cfg) $ run child
4949 {-# INLINABLE placeholder #-}
5050 placeholder cfg = lift $ do
51− rec childPostBuild <- deletable (cfg ^. deleteSelf) $ performEvent $ return () <$ _placeholder_insertedAbove p
51+ rec childPostBuild <- deletable (_placeholder_deletedSelf p) $ performEvent $ return () <$ _placeholder_insertedAbove p
5252 p <- placeholder $ cfg
5353 { _placeholderConfig_insertAbove = fmap (\a -> runPostBuildT a =<< headE childPostBuild) $ _placeholderConfig_insertAbove cfg
5454 }
src/Reflex/Dom/Widget/Basic.hs+1−1
@@ -65,7 +65,7 @@ listHoldWithKey initialChildren modifyChildren buildChild = do
6565 & deleteSelf .~ delete
6666 ph <- placeholder myCfg
6767 result <- deletable delete $ buildChild k v
68− return $ ChildResult (result, (fmap (fmap Just) $ _placeholder_insertedAbove ph) <> (Map.singleton k Nothing <$ _placeholder_deleted ph)) --Note: we could also use the "deleted" output on deletable, if it had one; we're using this so that everything changes all at once, instead of deletions being prompt and insertions being delayed
68+ return $ ChildResult (result, (fmap (fmap Just) $ _placeholder_insertedAbove ph) <> (Map.singleton k Nothing <$ _placeholder_deletedSelf ph)) --Note: we could also use the "deleted" output on deletable, if it had one; we're using this so that everything changes all at once, instead of deletions being prompt and insertions being delayed
6969 rec initialAugmentedResults <- iforM initialChildren buildAugmentedChild
7070 augmentedResults <- foldDyn applyMap initialAugmentedResults $ newInsertedBelow <> newInsertedAbove
7171 let newInsertedAbove = switch $ fmap (mconcat . reverse . fmap (snd . unChildResult) . Map.elems) $ current augmentedResults