Skip to content

Commit

Permalink
Feature: Add navigation.isLoading state to core/router store (#67680)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiankaegy authored Dec 9, 2024
1 parent 9da58a7 commit e85937f
Showing 1 changed file with 4 additions and 0 deletions.
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

0 comments on commit e85937f

Please sign in to comment.