agocorona / MFlow

(Haskell) Web application server with stateful, type safe user interactions and widget combinators
http://mflowdemo.herokuapp.com
Other
100 stars 12 forks source link

"push" function doesn't show data the first data update #65

Open nickgeoca opened 8 years ago

nickgeoca commented 8 years ago

Description: push function requires clicking the submit button one additional time in browser before it receives the data. In other words, push requires two data updates before it shows in browser. Line: haskell <** push Append 0 (do Version:

Note this code was found in the tutorial.

{-# LANGUAGE OverloadedStrings #-}

import MFlow.Wai.Blaze.Html.All
import System.IO.Unsafe
import Control.Concurrent.MVar

res = unsafePerformIO $ newEmptyMVar :: MVar Int  

main= runNavigation "" . step . page $ do
   "Hi, I' m not refreshed, unless you "
     ++>  wlink () "click here" 
     <++ " in which case, a navigation happens"

    <** (autoRefresh .  pageFlow "s" $ do
          n  <- "First  "  ++> getInt Nothing   <++ br
          n' <- "Second " ++> getInt (Just n)  <++ br
          liftIO $ putMVar res $ n + n' 
          noWidget 
         <** br ++> pageFlow "button" (submitButton "submit"))

    <** push Append 0  (do
            n <- liftIO  $ takeMVar res  
            b << (show n) ++> br ++> noWidget )
agocorona commented 8 years ago

I tried it with this project in FPcomplete:

https://www.fpcomplete.com/user/agocorona/autocloned/mflow-tests

the FPcomplete environment is fantastic, by the way

I just reproduced the problem using Edge and FIrefox

going back again to chrome, with a fresh incognito session the issue is also reproduced