From 1adfcad88ea99f023fa976aa6782c922f03114f5 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 4 Oct 2026 02:45:31 +0200 Subject: [PATCH] Name the watch a state change is for (novox/hq ADR 0201) --- node-tools/internal/launch/launch.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/node-tools/internal/launch/launch.go b/node-tools/internal/launch/launch.go index 22a39f5..9b626ab 100644 --- a/node-tools/internal/launch/launch.go +++ b/node-tools/internal/launch/launch.go @@ -231,12 +231,14 @@ func Start(module, entry string, env []string, mesh Bus, logf func(string, ...an result = answered } case "mesh/state.watch": - // Each change is asked of this child, in order; the watch is answered once the - // current values have been handed over, so a bundle that awaits it has the whole - // of the state before it goes on (ADR 0201). + // Each change is asked of this child, in order, naming the watch it is for by + // the id the child asked it with — two watches of one state are two handlers; + // the watch is answered once the current values have been handed over, so a + // bundle that awaits it has the whole of the state before it goes on (ADR 0201). var stop func() + watch := m.ID stop, err = mesh.Watch(m.Params, func(change json.RawMessage) error { - _, err := c.ask(module, "mesh/state", map[string]any{"change": change}, EventTimeout) + _, err := c.ask(module, "mesh/state", map[string]any{"watch": watch, "change": change}, EventTimeout) return err }) if err == nil {