From cd0094c17a7987f1f9297cec46905c360263fc46 Mon Sep 17 00:00:00 2001 From: Eric Tuvesson Date: Mon, 11 Sep 2023 10:24:53 +0200 Subject: [PATCH] chore: Update Listen to Page Router navigation (#5) --- javascript/reference/events.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/javascript/reference/events.md b/javascript/reference/events.md index 5da2d1c..31e12d5 100644 --- a/javascript/reference/events.md +++ b/javascript/reference/events.md @@ -62,7 +62,17 @@ Script.Outputs = { Navigated: "signal", }; -function onNavigated({ routerName, path, title, component }) { +function onNavigated({ + // The name of the router for example 'Main'. + routerName, + // The relative path on this page router. + // To get the fullpath, use `window.location.pathname`. + path, + title, + // The component name for example '/Pages/MyPage'. + // (this is a page in the 'Pages' folder) + component +}) { Script.Outputs.Navigated(); } @@ -70,6 +80,8 @@ Script.Signals.DidMount = function () { Noodl.Events.on("NoodlApp_Navigated", onNavigated); }; +// OnDestroy is called when the Script node is unmounted. +// Where we do some cleanup to remove the event listener. Script.OnDestroy = function () { Noodl.Events.off("NoodlApp_Navigated", onNavigated); };