Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
ecab7506
Commit
ecab7506
authored
Sep 20, 2019
by
James Laver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor Main
parent
4c51907c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
36 deletions
+12
-36
Main.purs
src/Main.purs
+12
-36
No files found.
src/Main.purs
View file @
ecab7506
module Main where
module Main where
import Prelude
import Prelude
(Unit, ($))
import Data.Maybe (fromJust)
import Data.Maybe (Maybe(..))
import Data.Nullable (toMaybe)
import DOM.Simple.Document (document)
import DOM.Simple.Console (log)
import Effect (Effect)
import Effect (Effect)
import Gargantext.Pages.Layout (dispatchAction)
import FFI.Simple ((...))
import Gargantext.Pages.Layout.Specs (layoutSpec)
import Reactix as R
import Gargantext.Pages.Layout.States (initAppState)
import Gargantext.Components.Layout (layout)
import Gargantext.Router (routing)
import Partial.Unsafe (unsafePartial)
import React as R
import ReactDOM as RDOM
import Record.Unsafe (unsafeSet)
import Routing.Hash (getHash, matches, setHash)
import Thermite as T
import Web.DOM.ParentNode (QuerySelector(..), querySelector)
import Web.HTML (window)
import Web.HTML.Window (document)
import Web.HTML.HTMLDocument (toParentNode)
setUnsafeComponentWillMount :: forall s. Effect Unit -> Record s -> Record (unsafeComponentWillMount :: Effect Unit | s)
setUnsafeComponentWillMount = unsafeSet "unsafeComponentWillMount"
main :: Effect Unit
main :: Effect Unit
main = do
main = paint $ toMaybe $ document ... "getElementById" $ [ "app" ]
state <- initAppState
where
case T.createReactSpec layoutSpec (const state) of
paint Nothing = log "[main] Container not found"
{ spec, dispatcher } -> void $ do
paint (Just c) = R.render (layout {}) c
let setRouting this = void $ do
matches routing (dispatchAction (dispatcher this))
spec' this = setUnsafeComponentWillMount (setRouting this) <$> (spec this)
document <- window >>= document
container <- unsafePartial (fromJust <$> querySelector (QuerySelector "#app") (toParentNode document))
h <- getHash
case h of
"" -> setHash "/"
_ -> do
setHash "/"
setHash h
let e = R.unsafeCreateElement (R.component "GargantextMain" spec') {} []
RDOM.render e container
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment