-
Notifications
You must be signed in to change notification settings - Fork 10
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
refactor: Improve communication between plugin and ui & bundle ui #36
Conversation
…endencies The plugin is relying on a timer that triggers a full refresh every second. This impacts UI responsiveness and increase resource usage. The UI script also uses a timer to figure out when the d3 library has finished loading. This commit addresses both issues by: * Replacing the first timer by a poll mechanism. When the API notifies on a change, a model change is added to a queue. The ui checks the queue for new updates and apply them. This allows for a cleaner execution model and improves responsiveness. * Using extra-scripts to bundle ui & d3 with webpack. This removes the second timer and have the side benefit of reducing the plugin's size by 5 due to treeshaking.
Thank you for this @agerardin!! I'll review this today or tomorrow and get it merged |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm testing this out locally and seeing: Module not found: Error: Can't resolve 'd3' in '$HOME/dev/joplin-graph-view/src/ui'
I think the d3.js file should remain checked into the repo. Are you installing that dependency somewhere outside the repository on your machine?
Hello! I have added d3 as a dependency in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple minor questions, but this is a great improvement! Thank you for bringing some real JS experience to the project haha
Hello! I have updated with your remarks. |
To follow up on this, I was looking for a mechanism to send message from the plugin to the view rather than polling the plugin for changes. This is currently not implemented. I have a pull request ready for enabling push notifications so I will start discussing it with Joplin's contributors. Until this happens, the current method will do! |
The plugin is relying on a timer that triggers a full refresh every second.
This impacts UI responsiveness and increase resource usage.
The UI script also uses a timer to figure out when the d3 library has finished loading.
This commit addresses both issues by:
Replacing the first timer by a poll mechanism. When the API notifies
on a change, a model change is added to a queue. The ui checks the queue
for new updates and apply them. This allows for a cleaner execution model
and improves responsiveness.
Using extra-scripts to bundle ui & d3 with webpack. This removes the
second timer and have the side benefit of reducing the plugin's size by
5 due to treeshaking.