Create infrastructure for resource pubsub and polling
What does this MR do?
The original motivation for this issue was a requirement that changes to timetracking data be propagated immediately throughout the Issuable (MRs & Issue) UI. Once I got started, @lbennett suggested it had potential to be abstracted into something more generally useful.
It didn't seem like it would take too much additional effort, so I converted what I was working on into two re-usable classes that would support polling and propagating changes throughout a page. The two classes introduced in this MR are SubbableResource
and SmartInterval
.
SubbableResource
can be extended to provide a pubsub-style service sending and receiving updates for a data source and propagating changes to subscribers throughout the page. It is usable by both Vue-ized and non-Vue-ized components.
Instances of SmartInterval
extend the functionality of setInterval
and make it more configurable. This is useful for efficiently polling resources.
There's more documentation in the code, as well as some examples of how I imagine it could be implemented.
Are there points in the code the reviewer needs to double check?
At this point, I'm looking for general input on the approach I'm taking here, in the hope that this can actually be re-used. What can I do to make it more re-usable? What use cases am I missing?
I think SmartInterval
could already create some quick perf wins (see https://gitlab.com/gitlab-org/gitlab-ce/issues/23845)
Does this MR meet the acceptance criteria?
-
CHANGELOG entry added -
Documentation created/updated -
API support added - Tests
-
Added for this feature/bug -
All builds are passing
-
-
Conform by the merge request performance guides -
Conform by the style guides -
Branch has no merge conflicts with master
(if it does - rebase it please) -
Squashed related commits together
What are the relevant issue numbers?
EE timetracking & https://gitlab.com/gitlab-org/gitlab-ce/issues/23845
Screenshots/Gifs
SmartInterval logs