> ## Documentation Index
> Fetch the complete documentation index at: https://easyaf.nimbleapps.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# AppStateBase

> A base class to control application-wide state in a Blazor app.

## Definition

**Assembly:** CloudNimble.BlazorEssentials.dll

**Namespace:** CloudNimble.BlazorEssentials

**Inheritance:** CloudNimble.BlazorEssentials.BlazorObservable

## Syntax

```csharp theme={"dark"}
CloudNimble.BlazorEssentials.AppStateBase
```

## Summary

A base class to control application-wide state in a Blazor app.

## Constructors

### &#x20;.ctor

#### Syntax

```csharp theme={"dark"}
public AppStateBase(Microsoft.AspNetCore.Components.NavigationManager navigationManager, System.Net.Http.IHttpClientFactory httpClientFactory, Microsoft.JSInterop.IJSRuntime jsRuntime, Microsoft.AspNetCore.Components.WebAssembly.Hosting.IWebAssemblyHostEnvironment environment, CloudNimble.BlazorEssentials.Navigation.NavigationHistory navHistory, CloudNimble.BlazorEssentials.StateHasChangedConfig stateHasChangedConfig = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `navigationManager` | `Microsoft.AspNetCore.Components.NavigationManager` | The Blazor [AppStateBase.NavigationManager](https://easyaf.nimbleapps.cloud/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase.md#navigationmanager) instance from the DI container. |
| `httpClientFactory` | `System.Net.Http.IHttpClientFactory` | The [IHttpClientFactory](https://learn.microsoft.com/dotnet/api/system.net.http.ihttpclientfactory) instance from the DI container. |
| `jsRuntime` | `Microsoft.JSInterop.IJSRuntime` | The [IJSRuntime](https://learn.microsoft.com/dotnet/api/microsoft.jsinterop.ijsruntime) instance from the DI container. |
| `environment` | `Microsoft.AspNetCore.Components.WebAssembly.Hosting.IWebAssemblyHostEnvironment` | The [IWebAssemblyHostEnvironment](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.components.webassembly.hosting.iwebassemblyhostenvironment) instance from the DI container. |
| `navHistory` | `CloudNimble.BlazorEssentials.Navigation.NavigationHistory` | The [AppStateBase.NavigationHistory](https://easyaf.nimbleapps.cloud/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase.md#navigationhistory) instance from the DI container. |
| `stateHasChangedConfig` | `CloudNimble.BlazorEssentials.StateHasChangedConfig` | The [StateHasChangedConfig](https://easyaf.nimbleapps.cloud/blazoressentials/api-reference/CloudNimble/BlazorEssentials/StateHasChangedConfig.md) instance from the DI container. |

### &#x20;.ctor Inherited

> [!NOTE]
>
> Inherited from `CloudNimble.BlazorEssentials.BlazorObservable`

Creates a new instance of the [BlazorObservable](https://easyaf.nimbleapps.cloud/blazoressentials/api-reference/CloudNimble/BlazorEssentials/BlazorObservable.md) class.

#### Syntax

```csharp theme={"dark"}
public BlazorObservable(CloudNimble.BlazorEssentials.StateHasChangedConfig stateHasChangedConfig = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `stateHasChangedConfig` | `CloudNimble.BlazorEssentials.StateHasChangedConfig` | - |

## Properties

### &#x20;AuthenticationStateProvider

The [AppStateBase.AuthenticationStateProvider](https://easyaf.nimbleapps.cloud/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase.md#authenticationstateprovider) instance for the application.

#### Syntax

```csharp theme={"dark"}
public Microsoft.AspNetCore.Components.Authorization.AuthenticationStateProvider AuthenticationStateProvider { get; set; }
```

#### Property Value

Type: `Microsoft.AspNetCore.Components.Authorization.AuthenticationStateProvider`

#### Remarks

This property correctly registers for and de-registers from [AppStateBase.AuthenticationStateProvider](https://easyaf.nimbleapps.cloud/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase.md#authenticationstateprovider) events as the
value is set, and automatically calls [AppStateBase.RefreshClaimsPrincipal](https://easyaf.nimbleapps.cloud/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase.md#refreshclaimsprincipal) for you.

### &#x20;ClaimsPrincipal

The [AppStateBase.ClaimsPrincipal](https://easyaf.nimbleapps.cloud/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase.md#claimsprincipal) returned from calling [User](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.components.authorization.authenticationstate.user).

#### Syntax

```csharp theme={"dark"}
public System.Security.Claims.ClaimsPrincipal ClaimsPrincipal { get; set; }
```

#### Property Value

Type: `System.Security.Claims.ClaimsPrincipal`

### &#x20;CurrentNavItem

The [NavigationItem](https://easyaf.nimbleapps.cloud/blazoressentials/api-reference/CloudNimble/BlazorEssentials/Navigation/NavigationItem.md) from [AppStateBase.NavItems](https://easyaf.nimbleapps.cloud/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase.md#navitems) that corresponds to the current Route.

#### Syntax

```csharp theme={"dark"}
public CloudNimble.BlazorEssentials.Navigation.NavigationItem CurrentNavItem { get; set; }
```

#### Property Value

Type: `CloudNimble.BlazorEssentials.Navigation.NavigationItem`

### &#x20;Environment

The [WebAssemblyHostEnvironment](https://learn.microsoft.com/dotnet/api/microsoft.aspnetcore.components.webassembly.hosting.webassemblyhostenvironment) injected from the DI container.

#### Syntax

```csharp theme={"dark"}
public Microsoft.AspNetCore.Components.WebAssembly.Hosting.IWebAssemblyHostEnvironment Environment { get; set; }
```

#### Property Value

Type: `Microsoft.AspNetCore.Components.WebAssembly.Hosting.IWebAssemblyHostEnvironment`

### &#x20;HttpClientFactory

The instance of the [IHttpClientFactory](https://learn.microsoft.com/dotnet/api/system.net.http.ihttpclientfactory) injected by the DI system.

#### Syntax

```csharp theme={"dark"}
public System.Net.Http.IHttpClientFactory HttpClientFactory { get; private set; }
```

#### Property Value

Type: `System.Net.Http.IHttpClientFactory`

### &#x20;IsClaimsPrincipalAuthenticated

Returns a value indicating whether or not the current [AppStateBase.ClaimsPrincipal](https://easyaf.nimbleapps.cloud/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase.md#claimsprincipal)ClaimsPrincipal's\</see> Identity is authenticated.

#### Syntax

```csharp theme={"dark"}
public bool IsClaimsPrincipalAuthenticated { get; }
```

#### Property Value

Type: `bool`

### &#x20;JSRuntime

#### Syntax

```csharp theme={"dark"}
public Microsoft.JSInterop.IJSRuntime JSRuntime { get; set; }
```

#### Property Value

Type: `Microsoft.JSInterop.IJSRuntime`

### &#x20;LoadingStatus Inherited

> [!NOTE]
>
> Inherited from `CloudNimble.BlazorEssentials.BlazorObservable`

A [BlazorObservable.LoadingStatus](https://easyaf.nimbleapps.cloud/blazoressentials/api-reference/CloudNimble/BlazorEssentials/BlazorObservable.md#loadingstatus) specifying the current state of the required data for this Observable.

#### Syntax

```csharp theme={"dark"}
public CloudNimble.BlazorEssentials.LoadingStatus LoadingStatus { get; set; }
```

#### Property Value

Type: `CloudNimble.BlazorEssentials.LoadingStatus`

### &#x20;NavigationHistory

Allows the application to interact with the browser's History API.

#### Syntax

```csharp theme={"dark"}
public CloudNimble.BlazorEssentials.Navigation.NavigationHistory NavigationHistory { get; private set; }
```

#### Property Value

Type: `CloudNimble.BlazorEssentials.Navigation.NavigationHistory`

#### Remarks

This really should be a part of the NavigationManager, but what do we know? ¯\_(ツ)\_/¯

### &#x20;NavigationManager

The instance of the [AppStateBase.NavigationManager](https://easyaf.nimbleapps.cloud/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase.md#navigationmanager) injected by the DI system.

#### Syntax

```csharp theme={"dark"}
public Microsoft.AspNetCore.Components.NavigationManager NavigationManager { get; private set; }
```

#### Property Value

Type: `Microsoft.AspNetCore.Components.NavigationManager`

### &#x20;NavItems

An [ObservableCollection\`1](https://learn.microsoft.com/dotnet/api/system.collections.objectmodel.observablecollection-1) containing the primary navigation details for the application.

#### Syntax

```csharp theme={"dark"}
public System.Collections.ObjectModel.ObservableCollection<CloudNimble.BlazorEssentials.Navigation.NavigationItem> NavItems { get; internal set; }
```

#### Property Value

Type: `System.Collections.ObjectModel.ObservableCollection<CloudNimble.BlazorEssentials.Navigation.NavigationItem>`

### &#x20;StateHasChanged Inherited

> [!NOTE]
>
> Inherited from `CloudNimble.BlazorEssentials.BlazorObservable`

Determines how to trigger StateHasChanged events in a Blazor component.

#### Syntax

```csharp theme={"dark"}
public CloudNimble.BlazorEssentials.StateHasChangedConfig StateHasChanged { get; set; }
```

#### Property Value

Type: `CloudNimble.BlazorEssentials.StateHasChangedConfig`

## Methods

### &#x20;Dispose Override

> [!NOTE]
>
> Inherited from `CloudNimble.BlazorEssentials.BlazorObservable`

#### Syntax

```csharp theme={"dark"}
protected override void Dispose(bool disposing)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `disposing` | `bool` | - |

### &#x20;LoadNavItems

Load the NavigationItems into [AppStateBase.NavItems](https://easyaf.nimbleapps.cloud/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase.md#navitems) and properly wire up the PropertyChanged event.

#### Syntax

```csharp theme={"dark"}
public void LoadNavItems(System.Collections.Generic.List<CloudNimble.BlazorEssentials.Navigation.NavigationItem> items)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `items` | `System.Collections.Generic.List<CloudNimble.BlazorEssentials.Navigation.NavigationItem>` | - |

### &#x20;Navigate

Navigates to the specified Uri and sets [AppStateBase.CurrentNavItem](https://easyaf.nimbleapps.cloud/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase.md#currentnavitem) to the matching [NavigationItem](https://easyaf.nimbleapps.cloud/blazoressentials/api-reference/CloudNimble/BlazorEssentials/Navigation/NavigationItem.md) in [AppStateBase.NavItems](https://easyaf.nimbleapps.cloud/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase.md#navitems).

#### Syntax

```csharp theme={"dark"}
public void Navigate(string uri, bool setCurrentNavItem = false)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `uri` | `string` | - |
| `setCurrentNavItem` | `bool` | Determines whether or not we should also set the CurrentNavItem. Usually this is no because the MainLayout should call |
| AppState.SetCurrentNavItem in OnParametersSet. This parameter gives you flexibility without potentially calling it twice. | | |

### &#x20;NavigateBackAsync

Utilizes the injected [AppStateBase.NavigationHistory](https://easyaf.nimbleapps.cloud/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase.md#navigationhistory) History API to navigate to the last entry in the history stack, and attempts
to set the [AppStateBase.CurrentNavItem](https://easyaf.nimbleapps.cloud/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase.md#currentnavitem).

#### Syntax

```csharp theme={"dark"}
public System.Threading.Tasks.Task NavigateBackAsync(bool setCurrentNavItem = false)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `setCurrentNavItem` | `bool` | Determines whether or not we should also set the CurrentNavItem. Usually this is no because the MainLayout should call |
| AppState.SetCurrentNavItem in OnParametersSet. This parameter gives you flexibility without potentially calling it twice. | | |

#### Returns

Type: `System.Threading.Tasks.Task`
A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) representing the completion state of the operation.

#### Remarks

Will not throw an exception if you are at the bottom of the History stack.

### &#x20;NavigateForwardAsync

Utilizes the injected [AppStateBase.NavigationHistory](https://easyaf.nimbleapps.cloud/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase.md#navigationhistory) History API to navigate to the next entry in the history stack, and attempts
to set the [AppStateBase.CurrentNavItem](https://easyaf.nimbleapps.cloud/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase.md#currentnavitem).

#### Syntax

```csharp theme={"dark"}
public System.Threading.Tasks.Task NavigateForwardAsync(bool setCurrentNavItem = false)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `setCurrentNavItem` | `bool` | Determines whether or not we should also set the CurrentNavItem. Usually this is no because the MainLayout should call |
| AppState.SetCurrentNavItem in OnParametersSet. This parameter gives you flexibility without potentially calling it twice. | | |

#### Returns

Type: `System.Threading.Tasks.Task`
A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) representing the completion state of the operation.

#### Remarks

Will not throw an exception if you are at the top of the History stack.

### &#x20;OpenInNewTab

#### Syntax

```csharp theme={"dark"}
public System.Threading.Tasks.Task OpenInNewTab(string url)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `url` | `string` | - |

#### Returns

Type: `System.Threading.Tasks.Task`

#### Remarks

[https://stackoverflow.com/a/62769092](https://stackoverflow.com/a/62769092)

### &#x20;RefreshClaimsPrincipal

Tells the AuthenticationProvider to get the latest ClaimsPrincipal and run it through the internal AuthenticationStateChanged handler.

#### Syntax

```csharp theme={"dark"}
public System.Threading.Tasks.Task RefreshClaimsPrincipal()
```

#### Returns

Type: `System.Threading.Tasks.Task`
A [Task](https://learn.microsoft.com/dotnet/api/system.threading.tasks.task) representing the completion state of the operation.

### &#x20;SetCurrentNavItem

Initializes [AppStateBase.CurrentNavItem](https://easyaf.nimbleapps.cloud/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase.md#currentnavitem) to the proper value based on the current route.

#### Syntax

```csharp theme={"dark"}
public void SetCurrentNavItem()
```

### &#x20;SetCurrentNavItem

Initializes [AppStateBase.CurrentNavItem](https://easyaf.nimbleapps.cloud/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase.md#currentnavitem) to the proper value based on the current route.

#### Syntax

```csharp theme={"dark"}
public void SetCurrentNavItem(string url)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `url` | `string` | - |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.