@workglow/task-graph 0.0.54 → 0.0.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.js CHANGED
@@ -2217,6 +2217,54 @@ class TaskGraph {
2217
2217
  this.on(name, fn);
2218
2218
  return () => this.off(name, fn);
2219
2219
  }
2220
+ subscribeToTaskStatus(callback) {
2221
+ const unsubscribes = [];
2222
+ const tasks = this.getTasks();
2223
+ tasks.forEach((task) => {
2224
+ const unsub = task.subscribe("status", (status) => {
2225
+ callback(task.config.id, status);
2226
+ });
2227
+ unsubscribes.push(unsub);
2228
+ });
2229
+ const handleTaskAdded = (taskId) => {
2230
+ const task = this.getTask(taskId);
2231
+ if (!task || typeof task.subscribe !== "function")
2232
+ return;
2233
+ const unsub = task.subscribe("status", (status) => {
2234
+ callback(task.config.id, status);
2235
+ });
2236
+ unsubscribes.push(unsub);
2237
+ };
2238
+ const graphUnsub = this.subscribe("task_added", handleTaskAdded);
2239
+ unsubscribes.push(graphUnsub);
2240
+ return () => {
2241
+ unsubscribes.forEach((unsub) => unsub());
2242
+ };
2243
+ }
2244
+ subscribeToDataflowStatus(callback) {
2245
+ const unsubscribes = [];
2246
+ const dataflows = this.getDataflows();
2247
+ dataflows.forEach((dataflow) => {
2248
+ const unsub = dataflow.subscribe("status", (status) => {
2249
+ callback(dataflow.id, status);
2250
+ });
2251
+ unsubscribes.push(unsub);
2252
+ });
2253
+ const handleDataflowAdded = (dataflowId) => {
2254
+ const dataflow = this.getDataflow(dataflowId);
2255
+ if (!dataflow || typeof dataflow.subscribe !== "function")
2256
+ return;
2257
+ const unsub = dataflow.subscribe("status", (status) => {
2258
+ callback(dataflow.id, status);
2259
+ });
2260
+ unsubscribes.push(unsub);
2261
+ };
2262
+ const graphUnsub = this.subscribe("dataflow_added", handleDataflowAdded);
2263
+ unsubscribes.push(graphUnsub);
2264
+ return () => {
2265
+ unsubscribes.forEach((unsub) => unsub());
2266
+ };
2267
+ }
2220
2268
  on(name, fn) {
2221
2269
  const dagEvent = EventTaskGraphToDagMapping[name];
2222
2270
  if (dagEvent) {
@@ -2839,4 +2887,4 @@ export {
2839
2887
  ArrayTask
2840
2888
  };
2841
2889
 
2842
- //# debugId=32538247DA95577364756E2164756E21
2890
+ //# debugId=6772374DFD30114E64756E2164756E21