-
Notifications
You must be signed in to change notification settings - Fork 27
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
Debounce the GraphQL subscription request call in 0.5 second #373
Conversation
…ecuted only when there are no more calls after 1 second.
Needs a bit more of testing, and perhaps a unit test — if not too hard. On Where the operatoin with ID If you open another view, such as the In the image above, the current operation Now with this branch. Operation Going to another view, such as the The |
Tested again today, and it worked fine in the UI. You can quickly click on the "Dashboard" and on the "Workflow" links, and only the final link is activated, once you have not clicked for at least 1 second. Then it generates only a single WebSocket request/subscription. |
Decreased the debounce timeout to 500 ms (per this thread). 1 second seemed too long, and the user could have to wait for the workflow to be displayed unnecessarily. 300ms was too short, and the browser would still submit 2 requests. 500ms works fine. I would prefer 200-300 ms (which I think is the limit of time UX suggests users can be made waiting for something to happen? I think), but because GScan components is triggering query/subscription, and that happens before views in Vue.js and VueRouter, we have no option but to delay a little longer :/ |
Added unit test, GitHub action passing, ready for review. |
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.
LGTM
Looks fine on the code front, I'm not sold on the debounce solution though, may need some convincing. If I understand correctly the aim is to solve these problems:
|
Moved to an issue: #388 |
This is a small change with no associated Issue.
The rationale for this PR, is that we avoid at least one unnecessary call to the server. At the moment, when a user visits the main page of Cylc UI, a dashboard view is displayed.
Due to the lifecycle of components/routes, we will get
GScan
being created and put on the layout.GScan
is a component that also triggers subscriptions. After a while, other components are created, and finally the view is done, and the other lifecycle methods are called in theDashboard
view.One of these lifecycle methods being
created
, where the view will register itself, and start a new subscription. This new subscription forces theWorkflowService
to update the existing query created byGScan
, and combine with theDashboard
query.But when that happens, the
GScan
query will have triggered at least one request to the server. The UI will stop theGScan
subscription, and start a new one forDashboard
, which is not optimal.This PR uses Lodash's
debounce
, with1
second timeout. Meaning that the function will be called, after nobody has called it for at least 1 second.Requirements check-list
CONTRIBUTING.md
and added my name as a Code Contributor.