Add flows:* events and deprecate nodes-* events

This commit is contained in:
Nick O'Leary
2020-09-29 16:29:10 +01:00
parent 605177dcf0
commit 22a301b55e
3 changed files with 43 additions and 10 deletions

View File

@@ -28,6 +28,7 @@ var flowUtil = require("./util");
var log;
var events = require("../events");
var redUtil = require("@node-red/util").util;
const hooks = require("../hooks");
var storage = null;
var settings = null;
@@ -292,6 +293,8 @@ function start(type,diff,muteLog) {
}
}
events.emit("flows:starting", {config: activeConfig, type: type, diff: diff})
var id;
if (type === "full") {
// A full start means everything should
@@ -352,6 +355,8 @@ function start(type,diff,muteLog) {
}
}
}
events.emit("flows:started", {config: activeConfig, type: type, diff: diff});
// Deprecated event
events.emit("nodes-started");
if (credentialsPendingReset === true) {
@@ -399,6 +404,8 @@ function stop(type,diff,muteLog) {
stopList = diff.changed.concat(diff.removed).concat(diff.linked);
}
events.emit("flows:stopping",{config: activeConfig, type: type, diff: diff})
for (var id in activeFlows) {
if (activeFlows.hasOwnProperty(id)) {
var flowStateChanged = diff && (diff.added.indexOf(id) !== -1 || diff.removed.indexOf(id) !== -1);
@@ -430,6 +437,8 @@ function stop(type,diff,muteLog) {
log.info(log._("nodes.flows.stopped-flows"));
}
}
events.emit("flows:stopped",{config: activeConfig, type: type, diff: diff});
// Deprecated event
events.emit("nodes-stopped");
});
}