Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add on mode init hook #3882

Merged
merged 6 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions platform/app/src/routes/Mode/Mode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Expand Down Expand Up @@ -341,6 +350,7 @@ export default function ModeRoute({
servicesManager,
extensionManager,
commandsManager,
appConfig,
});

/**
Expand Down
9 changes: 9 additions & 0 deletions platform/docs/docs/platform/modes/lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading