-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
UI: Polling Step 3 - Close connections when tabbing away #3953
Conversation
|
||
export default Mixin.create({ | ||
setupDocumentVisibility: function() { | ||
this.set('_visibilityHandler', this.get('visibilityHandler').bind(this)); |
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.
Will you ever have > 1 component with this mixin on a screen? Would you have a last one wins situation here?
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 think all components (or routes) would have their handlers run, right? Which is likely the desired behaviour.
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.
Yes to both! Job row and node row both mix this mixin in, so multiple components. Yes all components own their own handler and independently add and remove their own handlers. This prevents accidental side effects when paginating or sorting resulting in one component being destroyed and bringing down all the visibility handlers.
|
||
export default Mixin.create({ | ||
export default Mixin.create(WithVisibilityDetection, { |
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.
mixin the mixin 🐢🐢🐢
}, | ||
|
||
startWatchers() { | ||
assert('startWatchers needs to be overridden in the Route', false); |
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.
❤ little usage helpers like this
|
||
export default Mixin.create({ | ||
setupDocumentVisibility: function() { | ||
this.set('_visibilityHandler', this.get('visibilityHandler').bind(this)); |
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 guess I have the same question about nested routes as I do with multiple components - do outer routes have their handler overwritten by child routes here?
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.
Nope, independent handlers again.
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.
This is super cool! 😎
On the new mixins: there's an implicit dependency on the visibilityHandler
method on the object using the mixin. This feels a little bit tricky to me. Is there any reasonable way of making that dependency more explicit?
Good call. Something like what I did with the default nomad/ui/app/mixins/with-watchers.js Lines 16 to 18 in df54b6b
|
Yeah, the |
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.
Cool 👍! Fun that it was a relatively small change too.
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
Since browsers only support ~6 open connections to the same host at once, it's important to eagerly close connections to allow other tabs to resolve requests.
Example problem scenario:
/clients
in Tab A/clients
has n + 1 connections, 1 for the nodes list and n for the allocations of each nodeSolved problem scenario:
/clients
in Tab A/clients
has n + 1 connections, 1 for the nodes list and n for the allocations of each node