Callback function to handle signal events (idle, opened, active, closed)
Unsubscribe function to stop listening
import { listenSignal } from "./function/event";
const unsubscribe = listenSignal((event) => {
if (event.action === "opened") {
console.log("New signal opened:", event.signal);
} else if (event.action === "closed") {
console.log("Signal closed with PNL:", event.pnl.pnlPercentage);
}
});
// Later: stop listening
unsubscribe();
Subscribes to all signal events with queued async processing.
Events are processed sequentially in order received, even if callback is async. Uses queued wrapper to prevent concurrent execution of the callback.