Skip to content

Create infrastructure for resource pubsub and polling

username-removed-408230 requested to merge issuable-update-events into master

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?

What are the relevant issue numbers?

EE timetracking & https://gitlab.com/gitlab-org/gitlab-ce/issues/23845

Screenshots/Gifs

SmartInterval logs

2016-10-27_12.02.51

Merge request reports