diff --git a/app/assets/javascripts/lib/utils/communication.js b/app/assets/javascripts/lib/utils/communication.js new file mode 100644 index 0000000000000000000000000000000000000000..3af2afe5a101cf0bbdb7f40fe419ea4a33d1c7b5 --- /dev/null +++ b/app/assets/javascripts/lib/utils/communication.js @@ -0,0 +1,38 @@ +/** + * @module communication + */ + +/** + * [RxJS Observable Subject]{@link https://rxjs.dev/api/index/class/Subject} + * @typedef {Object} RxSubject + */ + +import { Subject } from 'rxjs'; + +const channels = {}; + +/** + * Open a channel on the communication harness + * @param {Object} [options] + * @param {String} [options.name] - The name of the channel to retrieve or create + * @returns {RxSubject} The requested channel, if it exists, or else a new channel + */ +export function openChannel({ name }) { + let channel = channels[name]; + + if (!channel) { + channel = new Subject(); + channels[name] = channel; + } + + return channel; +} + +/** + * Remove references to a channel from the communication harness + * @param {Object} [options] + * @param {String} [options.name] - The name of the channel to flush (forget/dereference) + */ +export function flushChannel({ name }) { + channels[name] = null; +} diff --git a/app/assets/javascripts/pipelines/components/graph/stage_column_component.vue b/app/assets/javascripts/pipelines/components/graph/stage_column_component.vue index 6ab4eb58977c1262d3369f3e6ac27915c28c758d..72b72642fad16004d869c013fa24ce4504ef3cb7 100644 --- a/app/assets/javascripts/pipelines/components/graph/stage_column_component.vue +++ b/app/assets/javascripts/pipelines/components/graph/stage_column_component.vue @@ -1,5 +1,6 @@