Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing caching. #11

Merged
merged 1 commit into from
Jun 13, 2024
Merged

Fix missing caching. #11

merged 1 commit into from
Jun 13, 2024

Conversation

jersonal-com
Copy link
Contributor

The decorator was not updating the cache. This improves performance and enables persistence of the state between sessions.

@CorvusYe
Copy link
Member

What I'm curious about is: isn't the old writing style equivalent to the new writing style.

What situation led to the necessity of this modification ?

But I believe you have your point. If possible, please share it with me.

@CorvusYe CorvusYe merged commit 58dc2af into graph-cn:main Jun 13, 2024
@@ -35,8 +35,10 @@ class PersistenceDecorator extends ForceDecorator {
void compute(Vertex v, Graph graph) {
super.compute(v, graph);
Vertex? cachedVertex = _positionMap[v];
if (cachedVertex == null || cachedVertex.position != v.position) {
if (cachedVertex == null || cachedVertex.position.x != v.position.x || cachedVertex.position.y != v.position.y ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you run "dart format ." and resubmit it again? If possible.
There is a formatting issue here.

@jersonal-com
Copy link
Contributor Author

Let me go back to the code - I messed around with my own code and might have to go for a different solution.
Comparing x and y separately was a leftover and clearly the positions should be compared directly.

The whole caching thing is aimed to persist the graph layout e.g. in a json file.

What I am struggling at the moment is to find an elegant way to write the data from the json file back via the onLoad function without it being instantaneously overwritten by the compute function. ;-)

Will get back to you on the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants