forked from paf31/purescript-thermite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.purs
41 lines (32 loc) · 1.31 KB
/
Main.purs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
-- | This task list application is made up of two Thermite components:
-- |
-- | - a component for a single task (Components.Task)
-- | - a component for a list of tasks (Components.TaskList)
-- |
-- | This example demonstrates the main features of a Thermite app:
-- |
-- | - Using `simpleSpec` to create simple components from `Render` and
-- | `PerformAction` functions
-- | - Composing components using the `Monoid` instance and lens combinators.
-- |
-- | For each component we start by declaring action and state types.
module Test.Main (main) where
import Prelude
import Data.Maybe.Unsafe
import Data.Nullable (toMaybe)
import Control.Monad.Eff
import Components.TaskList
import qualified Thermite as T
import qualified React as R
import qualified DOM as DOM
import qualified DOM.HTML as DOM
import qualified DOM.HTML.Types as DOM
import qualified DOM.HTML.Window as DOM
import qualified DOM.Node.ParentNode as DOM
-- | The main method creates the task list component, and renders it to the document body.
main :: Eff (dom :: DOM.DOM) Unit
main = void do
let component = T.createClass taskList initialTaskListState
document <- DOM.window >>= DOM.document
container <- fromJust <<< toMaybe <$> DOM.querySelector "#container" (DOM.htmlDocumentToParentNode document)
R.render (R.createFactory component {}) container