Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions src/Thermite.purs
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ instance monoidSpec :: Monoid (Spec eff state props action) where
createClass
:: forall eff state props action
. Spec eff state props action
-> state
-> React.GetInitialState props state eff
-> React.ReactClass props
createClass spec state = React.createClass <<< _.spec $ createReactSpec spec state
createClass spec getState = React.createClass <<< _.spec $ createReactSpec spec getState

-- | Create a React component spec from a Thermite component `Spec`.
-- |
Expand All @@ -210,7 +210,7 @@ createClass spec state = React.createClass <<< _.spec $ createReactSpec spec sta
createReactSpec
:: forall eff state props action
. Spec eff state props action
-> state
-> React.GetInitialState props state eff
-> { spec :: React.ReactSpec props state eff
, dispatcher :: React.ReactThis props state -> action -> EventHandler
}
Expand All @@ -227,13 +227,12 @@ createReactSpec'
:: forall eff state props action
. (Array React.ReactElement -> React.ReactElement)
-> Spec eff state props action
-> state
-> React.GetInitialState props state eff
-> { spec :: React.ReactSpec props state eff
, dispatcher :: React.ReactThis props state -> action -> EventHandler
}
createReactSpec' wrap (Spec spec) =
\state ->
{ spec: React.spec state render
createReactSpec' wrap (Spec spec) getState =
{ spec: React.spec' getState render
, dispatcher
}
where
Expand Down Expand Up @@ -276,11 +275,11 @@ createReactSpec' wrap (Spec spec) =
defaultMain
:: forall state props action eff
. Spec eff state props action
-> state
-> React.GetInitialState props state eff
-> props
-> Eff (dom :: DOM.DOM | eff) Unit
defaultMain spec initialState props = void do
let component = createClass spec initialState
defaultMain spec getState props = void do
let component = createClass spec getState
document <- DOM.window >>= DOM.document
container <- DOM.body document
traverse_ (render (createFactory component props) <<< DOM.htmlElementToElement) container
Expand Down
2 changes: 1 addition & 1 deletion test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ import Thermite as T

-- | The main method creates the task list component, and renders it to the document body.
main :: Eff (dom :: DOM.DOM) Unit
main = T.defaultMain taskList initialTaskListState unit
main = T.defaultMain taskList (const $ pure initialTaskListState) unit