ShadyNagy.Blazor.ComponentRefresh 1.0.6

Install-Package ShadyNagy.Blazor.ComponentRefresh -Version 1.0.6
dotnet add package ShadyNagy.Blazor.ComponentRefresh --version 1.0.6
<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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ShadyNagy.Blazor.ComponentRefresh, 1.0.6"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. 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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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

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 230 7/12/2020

Start of the project