Skip to content

Commit

Permalink
Merge pull request #436 from TimeWarpEngineering/Cramer/2024-07-19/Next
Browse files Browse the repository at this point in the history
Add ShouldReRender to the base interface and give it a default implem…
  • Loading branch information
StevenTCramer authored Jul 19, 2024
2 parents 708bc00 + 742bbb7 commit 47b1617
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Authors>Steven T. Cramer</Authors>
<Product>TimeWarp State</Product>
<PackageVersion>11.0.0-beta.52+8.0.303</PackageVersion>
<PackageVersion>11.0.0-beta.53+8.0.303</PackageVersion>
<PackageProjectUrl>https://timewarpengineering.github.io/blazor-state/</PackageProjectUrl>
<PackageTags>TimeWarp.State; TimeWarp-State; TimeWarpState; BlazorState; Blazor; State; Blazor-State; MediatR; Mediator; Pipeline; Redux; Flux</PackageTags>
<PackageIcon>Logo.png</PackageIcon>
Expand Down
2 changes: 2 additions & 0 deletions Source/TimeWarp.State/Components/ITimeWarpStateComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ public interface ITimeWarpStateComponent
string Id { get; }

void ReRender();

bool ShouldReRender(Type type) => true;
}
6 changes: 5 additions & 1 deletion Source/TimeWarp.State/Subscriptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ public void ReRenderSubscribers(Type type)
IEnumerable<Subscription> subscriptions = TimeWarpStateComponentReferencesList.Where(record => record.StateType == type);
foreach (Subscription subscription in subscriptions)
{
if (subscription.TimeWarpStateComponentReference.TryGetTarget(out ITimeWarpStateComponent? target))
if
(
subscription.TimeWarpStateComponentReference.TryGetTarget(out ITimeWarpStateComponent? target)
&& target.ShouldReRender(type)
)
{
LogReRender(subscription);
target.ReRender();
Expand Down

0 comments on commit 47b1617

Please sign in to comment.