> ## Documentation Index
> Fetch the complete documentation index at: https://easyaf.dev/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

### <Icon icon="hammer" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> .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](/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase#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](/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase#navigationhistory) instance from the DI container.                         |
| `stateHasChangedConfig` | `CloudNimble.BlazorEssentials.StateHasChangedConfig`                              | The [StateHasChangedConfig](/blazoressentials/api-reference/CloudNimble/BlazorEssentials/StateHasChangedConfig) instance from the DI container.                                           |

### <Icon icon="hammer" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> .ctor <Badge color="gray">Inherited</Badge>

<Note>Inherited from `CloudNimble.BlazorEssentials.BlazorObservable`</Note>

Creates a new instance of the [BlazorObservable](/blazoressentials/api-reference/CloudNimble/BlazorEssentials/BlazorObservable) class.

#### Syntax

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

#### Parameters

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

## Properties

### <Icon icon="tag" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> AuthenticationStateProvider

The [AppStateBase.AuthenticationStateProvider](/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase#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](/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase#authenticationstateprovider) events as the
value is set, and automatically calls [AppStateBase.RefreshClaimsPrincipal](/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase#refreshclaimsprincipal) for you.

### <Icon icon="tag" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> ClaimsPrincipal

The [AppStateBase.ClaimsPrincipal](/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase#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`

### <Icon icon="tag" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> CurrentNavItem

The [NavigationItem](/blazoressentials/api-reference/CloudNimble/BlazorEssentials/Navigation/NavigationItem) from [AppStateBase.NavItems](/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase#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`

### <Icon icon="tag" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> 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`

### <Icon icon="tag" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> 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`

### <Icon icon="tag" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> IsClaimsPrincipalAuthenticated

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

#### Syntax

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

#### Property Value

Type: `bool`

### <Icon icon="tag" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> JSRuntime

#### Syntax

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

#### Property Value

Type: `Microsoft.JSInterop.IJSRuntime`

### <Icon icon="tag" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> LoadingStatus <Badge color="gray">Inherited</Badge>

<Note>Inherited from `CloudNimble.BlazorEssentials.BlazorObservable`</Note>

A [BlazorObservable.LoadingStatus](/blazoressentials/api-reference/CloudNimble/BlazorEssentials/BlazorObservable#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`

### <Icon icon="tag" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> 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? ¯\_(ツ)\_/¯

### <Icon icon="tag" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> NavigationManager

The instance of the [AppStateBase.NavigationManager](/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase#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`

### <Icon icon="tag" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> 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>`

### <Icon icon="tag" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> StateHasChanged <Badge color="gray">Inherited</Badge>

<Note>Inherited from `CloudNimble.BlazorEssentials.BlazorObservable`</Note>

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

### <Icon icon="code-merge" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> Dispose <Badge color="blue">Override</Badge>

<Note>Inherited from `CloudNimble.BlazorEssentials.BlazorObservable`</Note>

#### Syntax

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

#### Parameters

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

### <Icon icon="function" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> LoadNavItems

Load the NavigationItems into [AppStateBase.NavItems](/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase#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>` | -           |

### <Icon icon="function" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> Navigate

Navigates to the specified Uri and sets [AppStateBase.CurrentNavItem](/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase#currentnavitem) to the matching [NavigationItem](/blazoressentials/api-reference/CloudNimble/BlazorEssentials/Navigation/NavigationItem) in [AppStateBase.NavItems](/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase#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. |          |                                                                                                                        |

### <Icon icon="function" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> NavigateBackAsync

Utilizes the injected [AppStateBase.NavigationHistory](/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase#navigationhistory) History API to navigate to the last entry in the history stack, and attempts
to set the [AppStateBase.CurrentNavItem](/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase#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.

### <Icon icon="function" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> NavigateForwardAsync

Utilizes the injected [AppStateBase.NavigationHistory](/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase#navigationhistory) History API to navigate to the next entry in the history stack, and attempts
to set the [AppStateBase.CurrentNavItem](/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase#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.

### <Icon icon="function" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> 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)

### <Icon icon="function" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> 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.

### <Icon icon="function" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> SetCurrentNavItem

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

#### Syntax

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

### <Icon icon="function" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> SetCurrentNavItem

Initializes [AppStateBase.CurrentNavItem](/blazoressentials/api-reference/CloudNimble/BlazorEssentials/AppStateBase#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` | -           |
