Const
Messages between a package's overlay pages and its own Node mod: a web UI with a Node backend. What one side posts, the other side's handlers get. Data must be plain JSON-like values.
Calls the handler for every message from the other side. Returns a function that stops it.
Sends data to the other side: from a mod to its pages, from a page to its mod.
// In the Node modimport { channel } from "rednode";channel.on((msg) => { if (msg.type === "ping") channel.post({ type: "pong" });});// In the package's pageimport { channel } from "rednode";channel.on((msg) => console.log(msg.type)); // "pong"channel.post({ type: "ping" }); Copy
// In the Node modimport { channel } from "rednode";channel.on((msg) => { if (msg.type === "ping") channel.post({ type: "pong" });});// In the package's pageimport { channel } from "rednode";channel.on((msg) => console.log(msg.type)); // "pong"channel.post({ type: "ping" });
Messages between a package's overlay pages and its own Node mod: a web UI with a Node backend. What one side posts, the other side's handlers get. Data must be plain JSON-like values.