From f58725ce40685f7297181ef98d81bc28420c8291 Mon Sep 17 00:00:00 2001 From: Igor Octaviano Date: Mon, 8 Jan 2024 16:12:26 -0300 Subject: [PATCH] feat: Add on mode init hook (#3882) --- platform/app/src/routes/Mode/Mode.tsx | 10 ++++++++++ platform/docs/docs/platform/modes/lifecycle.md | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/platform/app/src/routes/Mode/Mode.tsx b/platform/app/src/routes/Mode/Mode.tsx index 000a28fed..cb53db00c 100644 --- a/platform/app/src/routes/Mode/Mode.tsx +++ b/platform/app/src/routes/Mode/Mode.tsx @@ -124,6 +124,15 @@ export default function ModeRoute({ const params = useParams(); // The URL's query search parameters where the keys casing is maintained const query = useSearchParams(); + + mode?.onModeInit?.({ + servicesManager, + extensionManager, + commandsManager, + appConfig, + query, + }); + // The URL's query search parameters where the keys are all lower case. const lowerCaseSearchParams = useSearchParams({ lowerCaseKeys: true }); @@ -341,6 +350,7 @@ export default function ModeRoute({ servicesManager, extensionManager, commandsManager, + appConfig, }); /** diff --git a/platform/docs/docs/platform/modes/lifecycle.md b/platform/docs/docs/platform/modes/lifecycle.md index 92edeed5d..587fe1bbd 100644 --- a/platform/docs/docs/platform/modes/lifecycle.md +++ b/platform/docs/docs/platform/modes/lifecycle.md @@ -9,9 +9,18 @@ sidebar_label: Lifecycle Hooks Currently, there are two hooks that are called for modes: +- onModeInit - onModeEnter - onModeExit +## onModeInit + +This hook gets run before the defined route has been entered by the mode. This +hook can be used for initialization before the first render. + +This is called before `onModeEnter` calls. This allows modes to add or activate their own +data sources and configuration before entering the mode (pre registrations). + ## onModeEnter This hook gets run after the defined route has been entered by the mode. This