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
122
Issues
122
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
gargantext
purescript-gargantext
Commits
8f7a1b8b
Commit
8f7a1b8b
authored
Sep 07, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[graph] kill sigmajs after component unmount
Also, stop force atlas to make sure there are no leaks.
parent
9f0a0a6a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
6 deletions
+15
-6
Graph.purs
src/Gargantext/Components/Graph.purs
+11
-6
Sigma.purs
src/Gargantext/Hooks/Sigmax/Sigma.purs
+4
-0
No files found.
src/Gargantext/Components/Graph.purs
View file @
8f7a1b8b
...
@@ -49,6 +49,15 @@ graphCpt = R.hooksComponent "G.C.Graph" cpt
...
@@ -49,6 +49,15 @@ graphCpt = R.hooksComponent "G.C.Graph" cpt
cpt props _ = do
cpt props _ = do
stageHooks props
stageHooks props
R.useEffectOnce $ do
pure $ do
log "[graphCpt (Cleanup)]"
Sigmax.dependOnSigma (R.readRef props.sigmaRef) "[graphCpt (Cleanup)] no sigma" $ \sigma -> do
Sigma.stopForceAtlas2 sigma
log2 "[graphCpt (Cleanup)] forceAtlas stopped for" sigma
Sigma.kill sigma
log "[graphCpt (Cleanup)] sigma killed"
-- NOTE: This div is not empty after sigma initializes.
-- NOTE: This div is not empty after sigma initializes.
-- When we change state, we make it empty though.
-- When we change state, we make it empty though.
--pure $ RH.div { ref: props.elRef, style: {height: "95%"} } []
--pure $ RH.div { ref: props.elRef, style: {height: "95%"} } []
...
@@ -57,7 +66,7 @@ graphCpt = R.hooksComponent "G.C.Graph" cpt
...
@@ -57,7 +66,7 @@ graphCpt = R.hooksComponent "G.C.Graph" cpt
Just el -> R.createPortal [] el
Just el -> R.createPortal [] el
stageHooks props@{multiSelectEnabledRef, selectedNodeIds, sigmaRef, stage: (Init /\ setStage)} = do
stageHooks props@{multiSelectEnabledRef, selectedNodeIds, sigmaRef, stage: (Init /\ setStage)} = do
R.useEffectOnce $ do
R.useEffectOnce
'
$ do
let rSigma = R.readRef props.sigmaRef
let rSigma = R.readRef props.sigmaRef
case Sigmax.readSigma rSigma of
case Sigmax.readSigma rSigma of
...
@@ -103,11 +112,7 @@ graphCpt = R.hooksComponent "G.C.Graph" cpt
...
@@ -103,11 +112,7 @@ graphCpt = R.hooksComponent "G.C.Graph" cpt
setStage $ const Ready
setStage $ const Ready
delay unit $ \_ -> do
stageHooks props@{ showEdges: (showEdges /\ _), sigmaRef, stage: (Ready /\ setStage), transformedGraph } = do
log "[graphCpt] cleanup"
pure $ pure unit
stageHooks props@{showEdges: (showEdges /\ _), sigmaRef, stage: (Ready /\ setStage), transformedGraph} = do
let tEdgesMap = SigmaxTypes.edgesGraphMap transformedGraph
let tEdgesMap = SigmaxTypes.edgesGraphMap transformedGraph
let tNodesMap = SigmaxTypes.nodesGraphMap transformedGraph
let tNodesMap = SigmaxTypes.nodesGraphMap transformedGraph
...
...
src/Gargantext/Hooks/Sigmax/Sigma.purs
View file @
8f7a1b8b
...
@@ -46,6 +46,10 @@ type SigmaOpts s = { settings :: s }
...
@@ -46,6 +46,10 @@ type SigmaOpts s = { settings :: s }
sigma :: forall opts err. SigmaOpts opts -> Effect (Either err Sigma)
sigma :: forall opts err. SigmaOpts opts -> Effect (Either err Sigma)
sigma = runEffectFn3 _sigma Left Right
sigma = runEffectFn3 _sigma Left Right
-- | Kill a sigmajs instance.
kill :: Sigma -> Effect Unit
kill sigma = pure $ sigma ... "kill" $ []
-- | Call the `refresh()` method on a sigmajs instance.
-- | Call the `refresh()` method on a sigmajs instance.
refresh :: Sigma -> Effect Unit
refresh :: Sigma -> Effect Unit
refresh s = pure $ s ... "refresh" $ []
refresh s = pure $ s ... "refresh" $ []
...
...
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