ShadyNagy.Blazor.ComponentRefresh 1.0.6

dotnet add package ShadyNagy.Blazor.ComponentRefresh --version 1.0.6                
NuGet\Install-Package ShadyNagy.Blazor.ComponentRefresh -Version 1.0.6                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ShadyNagy.Blazor.ComponentRefresh" Version="1.0.6" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ShadyNagy.Blazor.ComponentRefresh --version 1.0.6                
#r "nuget: ShadyNagy.Blazor.ComponentRefresh, 1.0.6"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ShadyNagy.Blazor.ComponentRefresh as a Cake Addin
#addin nuget:?package=ShadyNagy.Blazor.ComponentRefresh&version=1.0.6

// Install ShadyNagy.Blazor.ComponentRefresh as a Cake Tool
#tool nuget:?package=ShadyNagy.Blazor.ComponentRefresh&version=1.0.6                

Blazor Component Refresh

Call refresh for all pages, Components and, layouts by call one function.

How To Use

  • After install from Nuget
Install-Package ShadyNagy.Blazor.ComponentRefresh
  • You have to inherit all LayoutComponent like "MainLayout.razor" from ShadyNagy.Blazor.BlazorLayoutComponent

Change this

@inherits LayoutComponentBase

to

@inherits ShadyNagy.Blazor.ComponentRefresh.BlazorLayoutComponent
  • You have to inherit all Component or page like "Counter.razor" from ShadyNagy.Blazor.BlazorComponent

Change this

@inherits ComponentBase

to

@inherits ShadyNagy.Blazor.ComponentRefresh.BlazorComponent
  • If you need to refresh all the components and layouts call this function CallRequestRefresh from any component or layout.
CallRequestRefresh();

Samples

You can find samples here https://github.com/ShadyNagy/BlazorComponentRefresh/tree/master/samples/SampleBlazorComponentRefresh

Sample applied to the counter page "Counter.razor" and NavMenu "NavMenu.razor" so when you click "Click me" in the counter page it will increment the value in counter and in nav menu.

NavMenu.razor

@inherits ShadyNagy.Blazor.ComponentRefresh.BlazorComponent

<div class="top-row pl-4 navbar navbar-dark">
    <a class="navbar-brand" href="">SampleBlazorComponentRefresh</a>
    <button class="navbar-toggler" @onclick="ToggleNavMenu">
        <span class="navbar-toggler-icon"></span>
    </button>
</div>

<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
    <ul class="nav flex-column">
        <li class="nav-item px-3">
            <NavLink class="nav-link" href="" Match="NavLinkMatch.All">
                <span class="oi oi-home" aria-hidden="true"></span> Home
            </NavLink>
        </li>
        <li class="nav-item px-3">
            <NavLink class="nav-link" href="counter">
                <span class="oi oi-plus" aria-hidden="true"></span> Counter @SomethingShared.CurrentCount
            </NavLink>
        </li>
        <li class="nav-item px-3">
            <NavLink class="nav-link" href="fetchdata">
                <span class="oi oi-list-rich" aria-hidden="true"></span> Fetch data
            </NavLink>
        </li>
    </ul>
</div>

@code {
    private bool collapseNavMenu = true;

    private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;

    private void ToggleNavMenu()
    {
        collapseNavMenu = !collapseNavMenu;
    }
}

Counter.razor

@page "/counter"

@inherits ShadyNagy.Blazor.ComponentRefresh.BlazorComponent

<h1>Counter</h1>

<p>Current count: @SomethingShared.CurrentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {

    private void IncrementCount()
    {
        SomethingShared.CurrentCount++;
        CallRequestRefresh();
    }
}

Animated Screenshots

component-refresh

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.6 550 7/12/2020

Start of the project