feat: Add on mode init hook (#3882)

This commit is contained in:
Igor Octaviano 2024-01-08 16:12:26 -03:00 committed by GitHub
parent 5a1cb842f0
commit f58725ce40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -124,6 +124,15 @@ export default function ModeRoute({
const params = useParams(); const params = useParams();
// The URL's query search parameters where the keys casing is maintained // The URL's query search parameters where the keys casing is maintained
const query = useSearchParams(); const query = useSearchParams();
mode?.onModeInit?.({
servicesManager,
extensionManager,
commandsManager,
appConfig,
query,
});
// The URL's query search parameters where the keys are all lower case. // The URL's query search parameters where the keys are all lower case.
const lowerCaseSearchParams = useSearchParams({ lowerCaseKeys: true }); const lowerCaseSearchParams = useSearchParams({ lowerCaseKeys: true });
@ -341,6 +350,7 @@ export default function ModeRoute({
servicesManager, servicesManager,
extensionManager, extensionManager,
commandsManager, commandsManager,
appConfig,
}); });
/** /**

View File

@ -9,9 +9,18 @@ sidebar_label: Lifecycle Hooks
Currently, there are two hooks that are called for modes: Currently, there are two hooks that are called for modes:
- onModeInit
- onModeEnter - onModeEnter
- onModeExit - 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 ## onModeEnter
This hook gets run after the defined route has been entered by the mode. This This hook gets run after the defined route has been entered by the mode. This