Wednesday, May 01, 2013

A web application in a tweet

Playing yesterday to send a tweet about the previous post, I managed to put an application in a tweet:

Here below there is a complete application with three pages. In a loop, it ask for two numbers (it show two times a form with a text field asking for a number) . The third page show the sum and a link to  asking the next pair of numbers (The flow will restart again when it finish).

You can press the back button as you please. For example when you see the sum, you can press back one time, fill another number and see the sum of the first number with this new second number. The state is automatically synchronized with the navigation:

import MFlow.Wai.Blaze.Html.All

main= runNavigation "sum" . step $ do
       n1 <- get
       n2 <- get
       ask $ p << (n1+n2) ++> wlink () "click"
  
  where
  get= ask $ getInt Nothing


And the tweet:

See the previous post for the same example not soo terse, with a few more things.
Post a Comment