Skip to content

Commit

Permalink
Add ForceLoad to GoAction #178 (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrpmorris committed Nov 4, 2021
1 parent 1af761c commit 37d7478
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Docs/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
## New in 4.2
* New `[FeatureState]` attribute to avoid having to create `Feature<T>` descendant classes. ([#204](https://github.com/mrpmorris/Fluxor/issues/204))
* Add `FluxorOptions.ScanTypes` to allow scanning of specified classes. ([#214](https://github.com/mrpmorris/Fluxor/issues/214))
* Make `FluxorComponent` and `FluxorLayout` abstract ([#217](https://github.com/mrpmorris/Fluxor/issues/217))
* Make `FluxorComponent` and `FluxorLayout` abstract. ([#217](https://github.com/mrpmorris/Fluxor/issues/217))
* Add `ForceLoad` property to `GoAction`. ([#178](https://github.com/mrpmorris/Fluxor/issues/178))

## New in 4.1
* Allow custom control over JSON serialisation in Redux Dev Tools - see
Expand Down
7 changes: 4 additions & 3 deletions Source/Fluxor.Blazor.Web/Middlewares/Routing/Effects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ public Effects(NavigationManager navigationManager)
public Task HandleGoActionAsync(GoAction action, IDispatcher dispatcher)
{
Uri fullUri = NavigationManager.ToAbsoluteUri(action.NewUri);
if (fullUri.ToString() != NavigationManager.Uri)
if (fullUri.ToString() != NavigationManager.Uri || action.ForceLoad)
{
// Only navigate if we are not already at the URI specified
NavigationManager.NavigateTo(action.NewUri);
// Only navigate if we are not already at the URI specified,
// or if we have been told to do a proper page reload (ForceLoad)
NavigationManager.NavigateTo(action.NewUri, action.ForceLoad);
}
return Task.CompletedTask;
}
Expand Down
7 changes: 6 additions & 1 deletion Source/Fluxor.Blazor.Web/Middlewares/Routing/GoAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ public class GoAction
/// </summary>
public string NewUri { get; }

/// <summary>
/// When true forces a real browser navigation and page reload
/// </summary>
public bool ForceLoad { get; }

/// <summary>
/// Creates a new instance of the action
/// </summary>
/// <param name="newUri"></param>
public GoAction(string newUri)
public GoAction(string newUri, bool forceLoad = false)
{
NewUri = newUri;
}
Expand Down

0 comments on commit 37d7478

Please sign in to comment.