New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated for halogen 0.8.0 and router 0.4.0 #2

Merged
merged 1 commit into from Jun 12, 2016
File filter...
Filter file types
Jump to file or symbol
Failed to load files and symbols.
+18 −17
Diff settings

Always

Just for now

updated for halogen 0.8.0 and router 0.4.0

  • Loading branch information...
sportanova committed Jun 12, 2016
commit e9c3325fc3d3bbaaadda65054044f1e05fe6b6aa
Copy path View file
@@ -12,8 +12,8 @@
],
"dependencies": {
"purescript-console": "^0.1.0",
"purescript-halogen": "~0.5.2",
"purescript-halogen": "^0.8.0",
"purescript-generics": "~0.7.0",
"purescript-routing": "~0.2.0"
"purescript-routing": "~0.4.0"
}
}
Copy path View file
@@ -22,13 +22,13 @@ instance ordGeneric :: Ord Slot where
compare = gCompare

ui :: forall g. (Functor g) => Component State Input g
ui = component render eval
ui = component { render, eval }
where
render _ =
H.div_
[ H.h1_ [ H.text "Your Profile" ]
, H.p_ [ H.text "what a nice profile!" ]
]

eval :: Eval _ _ _ g
eval :: Natural Input (ComponentDSL State Input g)
eval (Noop n) = pure n
Copy path View file
@@ -21,13 +21,13 @@ instance eqSlot :: Eq Slot where
instance ordGeneric :: Ord Slot where
compare = gCompare
ui :: forall g. (Functor g) => Component State Input g
ui = component render eval
ui = component { render, eval }
where
render _ =
H.div_
[ H.h1_ [ H.text "Your Sessions" ]
, H.p_ [ H.text "wow you lift a LOT" ]
]

eval :: Eval _ _ _ g
eval :: Natural Input (ComponentDSL State Input g)
eval (Noop n) = pure n
Copy path View file
@@ -5,13 +5,13 @@ import BigPrelude
import Control.Monad.Aff (runAff, forkAff)

import Halogen
import Halogen.Util (appendToBody)
import Halogen.Util
import Control.Monad.Eff.Exception (throwException)

import qualified Router as R

main :: forall eff. Eff (R.Effects eff) Unit
main = runAff throwException (const (pure unit)) $ do
app <- runUI R.ui (installedState R.init)
appendToBody app.node
forkAff $ R.routeSignal app.driver
body <- awaitBody
driver <- runUI R.ui (parentState R.init) body
forkAff $ R.routeSignal driver
Copy path View file
@@ -25,7 +25,7 @@ import Routing.Match.Class
import qualified Component.Profile as Profile
import qualified Component.Sessions as Sessions

data Input a
data Input a
= Goto Routes a

data CRUD
@@ -52,7 +52,7 @@ routing = profile
parseCRUD = Show <$> num <|> pure Index

type State =
{ currentPage :: String
{ currentPage :: String
}

type ChildState = Either Profile.State Sessions.State
@@ -66,15 +66,16 @@ pathToSessions :: ChildPath Sessions.State ChildState Sessions.Input ChildQuery
pathToSessions = cpR

type StateP g
= InstalledState State ChildState Input ChildQuery g ChildSlot
= ParentState State ChildState Input ChildQuery g ChildSlot

type QueryP
= Coproduct Input (ChildF ChildSlot ChildQuery)

ui :: forall g. (Plus g)
ui :: forall g. (Plus g)
=> Component (StateP g) QueryP g
ui = parentComponent render eval
ui = parentComponent { render, eval, peek: Nothing }
where
render :: State -> ParentHTML ChildState Input ChildQuery g ChildSlot
render st =
H.div_
[ H.h1_ [ H.text (st.currentPage) ]
@@ -92,7 +93,7 @@ ui = parentComponent render eval
viewPage _ =
H.div_ []

eval :: EvalParent Input State ChildState Input ChildQuery g ChildSlot
eval :: Natural Input (ParentDSL State ChildState Input ChildQuery g ChildSlot)
eval (Goto Profile next) = do
modify (_ { currentPage = "Profile" })
pure next
@@ -119,7 +120,7 @@ redirects :: forall eff. Driver QueryP eff
-> Aff (Effects eff) Unit
redirects driver _ =
driver <<< left <<< action <<< Goto
-- redirects driver _ Home =
-- redirects driver _ Home =
-- driver (left (action (Goto Home))))
-- redirects driver _ Profile =
-- driver (left (action (Goto Profile))))
ProTip! Use n and p to navigate between commits in a pull request.