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
992172f4
Unverified
Commit
992172f4
authored
Oct 14, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NgramsTable,useReductor: argument flip and cleaup
parent
e93e14f2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
16 deletions
+17
-16
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+14
-13
Sessions.purs
src/Gargantext/Sessions.purs
+1
-1
Reactix.purs
src/Gargantext/Utils/Reactix.purs
+2
-2
No files found.
src/Gargantext/Components/NgramsTable.purs
View file @
992172f4
...
...
@@ -30,7 +30,8 @@ import React (ReactElement)
import React.DOM (a, i, input, li, span, text, ul)
import React.DOM.Props (_type, checked, className, onChange, onClick, style)
import React.DOM.Props as DOM
import Thermite (PerformAction, Render, Spec, modifyState_, simpleSpec)
import Thermite as Thermite
import Thermite (modifyState_)
import Gargantext.Types
( CTabNgramType, OrderBy(..), TabType, TermList(..), readTermList
, readTermSize, termLists, termSizes)
...
...
@@ -181,14 +182,6 @@ data Action'
| ToggleChild' (Maybe NgramsTerm) NgramsTerm
| Refresh'
performNgramsAction :: State -> Action' -> State
performNgramsAction st (SetParentResetChildren' term) = st
performNgramsAction st (ToggleChild' b c) = st
performNgramsAction st Refresh' = st
useNgramsReducer :: State -> R.Hooks (R.Reducer State Action')
useNgramsReducer init = R.useReducer' performNgramsAction init
type Props =
( session :: Session
, tabNgramType :: CTabNgramType
...
...
@@ -205,13 +198,21 @@ loadedNgramsTableCpt = R.hooksComponent "G.C.NgramsTable.loadedNgramsTable" cpt
state <- useNgramsReducer (initialState versioned)
pure $ R.fragment []
ngramsTableSpec :: Session -> CTabNgramType -> R2.Setter PageParams -> Spec State (Record LoadedNgramsTableProps) Action
ngramsTableSpec session ntype setPath = simpleSpec performAction render
useNgramsReducer :: State -> R.Hooks (R.Reducer State Action')
useNgramsReducer init = R2.useReductor' performNgramsAction init
performNgramsAction :: Action' -> State -> Effect State
performNgramsAction (SetParentResetChildren' term) = pure -- TODO
performNgramsAction (ToggleChild' b c) = pure -- TODO
performNgramsAction Refresh' = pure -- TODO
ngramsTableSpec :: Session -> CTabNgramType -> R2.Setter PageParams -> Thermite.Spec State (Record LoadedNgramsTableProps) Action
ngramsTableSpec session ntype setPath = Thermite.simpleSpec performAction render
where
setParentResetChildren :: Maybe NgramsTerm -> State -> State
setParentResetChildren p = _ { ngramsParent = p, ngramsChildren = mempty }
performAction :: PerformAction State (Record LoadedNgramsTableProps) Action
performAction ::
Thermite.
PerformAction State (Record LoadedNgramsTableProps) Action
performAction (SetParentResetChildren p) _ _ =
modifyState_ $ setParentResetChildren p
performAction (ToggleChild b c) _ _ =
...
...
@@ -242,7 +243,7 @@ ngramsTableSpec session ntype setPath = simpleSpec performAction render
where
pt = addNewNgram ntype ngram CandidateTerm
render :: Render State (Record LoadedNgramsTableProps) Action
render ::
Thermite.
Render State (Record LoadedNgramsTableProps) Action
render dispatch { path: pageParams
, loaded: Versioned { data: initTable } }
{ ngramsTablePatch, ngramsParent, ngramsChildren }
...
...
src/Gargantext/Sessions.purs
View file @
992172f4
...
...
@@ -118,7 +118,7 @@ useSessions :: R.Hooks (R2.Reductor Sessions Action)
useSessions = R2.useReductor actAndSave (const loadSessions) unit
where
actAndSave :: R2.Actor Sessions Action
actAndSave
s a
= act s a >>= saveSessions
actAndSave
a s
= act s a >>= saveSessions
lookup :: SessionId -> Sessions -> Maybe Session
lookup sid (Sessions {sessions:ss}) = Seq.head (Seq.filter f ss) where
...
...
src/Gargantext/Utils/Reactix.purs
View file @
992172f4
...
...
@@ -29,7 +29,7 @@ newtype Point = Point { x :: Number, y :: Number }
-- a setter function, for useState
type Setter t = (t -> t) -> Effect Unit
-- a reducer function living in effector, for useReductor
type Actor
t a = (t -> a -> Effect t
)
type Actor
s a = (a -> s -> Effect s
)
-- | Turns a ReactElement into aReactix Element
-- | buff (v.) to polish
...
...
@@ -158,7 +158,7 @@ type Reductor state action = Tuple state (action -> Effect Unit)
useReductor :: forall s a i. Actor s a -> (i -> Effect s) -> i -> R.Hooks (Reductor s a)
useReductor f i j =
hook $ \_ ->
pure $ currySecond $ tuple $ react ... "useReducer" $ args3 (mkEffectFn2
f
) j (mkEffectFn1 i)
pure $ currySecond $ tuple $ react ... "useReducer" $ args3 (mkEffectFn2
(flip f)
) j (mkEffectFn1 i)
-- | Like `useReductor`, but takes an initial state instead of an
-- | initialiser function and argument
...
...
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