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

Feature: Add navigation.isLoading state to core/router store #67680

Merged
Merged
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
4 changes: 4 additions & 0 deletions packages/interactivity-router/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ interface Store {
state: {
url: string;
navigation: {
isLoading: boolean;
hasStarted: boolean;
hasFinished: boolean;
};
Expand All @@ -237,6 +238,7 @@ export const { state, actions } = store< Store >( 'core/router', {
state: {
url: window.location.href,
navigation: {
isLoading: false,
hasStarted: false,
hasFinished: false,
},
Expand Down Expand Up @@ -289,6 +291,7 @@ export const { state, actions } = store< Store >( 'core/router', {
return;
}

navigation.isLoading = true;
if ( loadingAnimation ) {
navigation.hasStarted = true;
navigation.hasFinished = false;
Expand Down Expand Up @@ -328,6 +331,7 @@ export const { state, actions } = store< Store >( 'core/router', {

// Update the navigation status once the the new page rendering
// has been completed.
navigation.isLoading = false;
if ( loadingAnimation ) {
navigation.hasStarted = false;
navigation.hasFinished = true;
Expand Down
Loading