Skip to content

Commit

Permalink
Merge pull request #296 from mrpmorris/release/5.2
Browse files Browse the repository at this point in the history
Release/5.2
  • Loading branch information
mrpmorris committed May 3, 2022
2 parents d86b0c0 + 4eebae6 commit 97997c7
Show file tree
Hide file tree
Showing 76 changed files with 2,258 additions and 119 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Fluxor
![](./Images/fluxor-logo.png)

Fluxor is a zero boilerplate Flux/Redux library for [Microsoft DotNet](https://dotnet.microsoft.com/).
***Fluxor*** is a zero boilerplate Flux/Redux library for [Microsoft .NET](https://dotnet.microsoft.com/)

[![Join the chat at https://gitter.im/mrpmorris/fluxor](https://badges.gitter.im/mrpmorris/fluxor.svg)](https://gitter.im/mrpmorris/fluxor?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Expand Down
7 changes: 7 additions & 0 deletions Source/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<Project>
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<LangVersion>9</LangVersion>
<Version>5.2.0</Version>
<AssemblyVersion>5.2.0.0</AssemblyVersion>
<FileVersion>5.2.0.0</FileVersion>
Expand All @@ -25,4 +27,9 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>NU5118</NoWarn>
</PropertyGroup>

<ItemGroup>
<SupportedPlatform Include="browser" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<Product>ReduxDevTools for Fluxor Blazor (Web)</Product>
<Description>Middleware link from a Blazor (Web) Fluxor store to the Redux Dev Tools browser extension for Chrome.</Description>
<PackageIcon>fluxor-blazor-reduxdevtools-small.png</PackageIcon>
<PackageTags>Redux Flux DotNet CSharp Blazor RazorComponents ReduxDevTools</PackageTags>
</PropertyGroup>
<PropertyGroup>
<Product>ReduxDevTools for Fluxor Blazor (Web)</Product>
<Description>Middleware link from a Blazor (Web) Fluxor store to the Redux Dev Tools browser extension for Chrome.</Description>
<PackageIcon>fluxor-blazor-reduxdevtools-small.png</PackageIcon>
<PackageTags>Redux Flux DotNet CSharp Blazor RazorComponents ReduxDevTools</PackageTags>
<SignAssembly Condition="'$(Configuration)'=='Release'" >True</SignAssembly>
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<LangVersion>9</LangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components" Version="3.1.8" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.1.8" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
<PropertyGroup>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Fluxor.Blazor.Web\Fluxor.Blazor.Web.csproj" />
<ProjectReference Include="..\Fluxor\Fluxor.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\Images\fluxor-blazor-reduxdevtools-small.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Fluxor.Blazor.Web\Fluxor.Blazor.Web.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\Images\fluxor-blazor-reduxdevtools-small.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Fluxor.Blazor.Web.ReduxDevTools;
using Fluxor.DependencyInjection;
using Fluxor.Extensions;
using Microsoft.Extensions.DependencyInjection;
using System;

Expand All @@ -21,10 +22,12 @@ public static class OptionsReduxDevToolsExtensions
updateReduxOptions?.Invoke(reduxOptions);

options.AddMiddleware<ReduxDevToolsMiddleware>();
options.Services.AddScoped<ReduxDevToolsInterop>();
options.Services.AddScoped(_ => reduxOptions);
options.Services.Add<ReduxDevToolsInterop>(options);
options.Services.Add(_ => reduxOptions, options);
options.UseRouting();
return options;
}

}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Fluxor.Blazor.Web.ReduxDevTools.Serialization;
using Fluxor.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Fluxor.Extensions;
using Newtonsoft.Json;
using System;
using System.Text.Json;
Expand Down Expand Up @@ -63,7 +63,7 @@ public ReduxDevToolsMiddlewareOptions(FluxorOptions fluxorOptions)
#endif
public ReduxDevToolsMiddlewareOptions EnableStackTrace(
int limit = 0,
string stackTraceFilterExpression =
string stackTraceFilterExpression =
@"^(?:(?!\b" +
@"System" +
@"|Microsoft" +
Expand Down Expand Up @@ -91,7 +91,7 @@ public ReduxDevToolsMiddlewareOptions(FluxorOptions fluxorOptions)
JsonSerializerSettings settings = getSettings?.Invoke(sp);
return new NewtonsoftJsonAdapter(settings);
});
FluxorOptions.Services.AddScoped<IJsonSerialization, NewtonsoftJsonAdapter>(implementationFactory);
FluxorOptions.Services.Add<IJsonSerialization, NewtonsoftJsonAdapter>(implementationFactory, FluxorOptions);
return this;
}

Expand All @@ -108,7 +108,7 @@ public ReduxDevToolsMiddlewareOptions(FluxorOptions fluxorOptions)
JsonSerializerOptions jsonOptions = getOptions?.Invoke(sp);
return new SystemTextJsonAdapter(jsonOptions);
});
FluxorOptions.Services.AddScoped<IJsonSerialization, SystemTextJsonAdapter>(implementationFactory);
FluxorOptions.Services.Add<IJsonSerialization, SystemTextJsonAdapter>(implementationFactory, FluxorOptions);
return this;
}
}
Expand Down
8 changes: 6 additions & 2 deletions Source/Fluxor.Blazor.Web/Components/FluxorComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ public void SubscribeToAction<TAction>(Action<TAction> callback)
{
ActionSubscriber.SubscribeToAction<TAction>(this, action =>
{
if (!Disposed)
callback(action);
InvokeAsync(() =>
{
if (!Disposed)
callback(action);
StateHasChanged();
});
});
}

Expand Down
8 changes: 6 additions & 2 deletions Source/Fluxor.Blazor.Web/Components/FluxorLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ public void SubscribeToAction<TAction>(Action<TAction> callback)
{
ActionSubscriber.SubscribeToAction<TAction>(this, action =>
{
if (!Disposed)
callback(action);
InvokeAsync(() =>
{
if (!Disposed)
callback(action);
StateHasChanged();
});
});
}

Expand Down
48 changes: 24 additions & 24 deletions Source/Fluxor.Blazor.Web/Fluxor.Blazor.Web.csproj
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<Product>Fluxor for Blazor (Web)</Product>
<Description>A zero boilerplate Redux/Flux framework for Blazor</Description>
<PackageIcon>fluxor-blazor-logo-small.png</PackageIcon>
<PackageTags>Redux Flux DotNet CSharp Blazor RazorComponents</PackageTags>
</PropertyGroup>
<PropertyGroup>
<Product>Fluxor for Blazor (Web)</Product>
<Description>A zero boilerplate Redux/Flux framework for Blazor</Description>
<PackageIcon>fluxor-blazor-logo-small.png</PackageIcon>
<PackageTags>Redux Flux DotNet CSharp Blazor RazorComponents</PackageTags>
<SignAssembly Condition="'$(Configuration)'=='Release'" >True</SignAssembly>
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<LangVersion>9</LangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>
<PropertyGroup>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components" Version="3.1.8" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.1.8" />
</ItemGroup>
<ItemGroup>
<PackageReference Condition="'$(TargetFramework)' == 'net6.0'" Include="Microsoft.AspNetCore.Components.Web" Version="6.0.0" />
<PackageReference Condition="'$(TargetFramework)' == 'net5.0'" Include="Microsoft.AspNetCore.Components.Web" Version="5.0.0" />
<PackageReference Condition="'$(TargetFramework)' != 'net6.0' AND '$(TargetFramework)' != 'net5.0'" Include="Microsoft.AspNetCore.Components.Web" Version="3.1.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Fluxor\Fluxor.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Fluxor\Fluxor.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\Images\fluxor-blazor-logo-small.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<None Include="..\..\Images\fluxor-blazor-logo-small.png">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>
</Project>
48 changes: 48 additions & 0 deletions Source/Fluxor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "01E-ActionSubscriber", "01E
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BasicConcepts.ActionSubscriber", "..\Tutorials\01-BasicConcepts\01E-ActionSubscriber\ActionSubscriber\BasicConcepts.ActionSubscriber.csproj", "{E7D0352B-16E1-4A89-8C29-ED119FF03316}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "02E-ActionSubscriberTutorial", "02E-ActionSubscriberTutorial", "{B5E9B3FC-1304-4A74-B0A9-607282AB2FD0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluxorBlazorWeb.ActionSubscriberTutorial.Server", "..\Tutorials\02-Blazor\02E-ActionSubscriber\FluxorBlazorWeb.ActionSubscriberTutorial\Server\FluxorBlazorWeb.ActionSubscriberTutorial.Server.csproj", "{E4C3711D-597C-4197-9128-E2D2189CC64E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluxorBlazorWeb.ActionSubscriberTutorial.Client", "..\Tutorials\02-Blazor\02E-ActionSubscriber\FluxorBlazorWeb.ActionSubscriberTutorial\Client\FluxorBlazorWeb.ActionSubscriberTutorial.Client.csproj", "{3E8452CA-14A3-432E-8378-99EAC13E5EED}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FluxorBlazorWeb.ActionSubscriberTutorial.Contracts", "..\Tutorials\02-Blazor\02E-ActionSubscriber\FluxorBlazorWeb.ActionSubscriberTutorial\Shared\FluxorBlazorWeb.ActionSubscriberTutorial.Contracts\FluxorBlazorWeb.ActionSubscriberTutorial.Contracts.csproj", "{C2332CB0-EE05-46EE-8E3D-0047138B32EC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -338,6 +346,42 @@ Global
{E7D0352B-16E1-4A89-8C29-ED119FF03316}.Release|iPhone.Build.0 = Release|Any CPU
{E7D0352B-16E1-4A89-8C29-ED119FF03316}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{E7D0352B-16E1-4A89-8C29-ED119FF03316}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{E4C3711D-597C-4197-9128-E2D2189CC64E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E4C3711D-597C-4197-9128-E2D2189CC64E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E4C3711D-597C-4197-9128-E2D2189CC64E}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{E4C3711D-597C-4197-9128-E2D2189CC64E}.Debug|iPhone.Build.0 = Debug|Any CPU
{E4C3711D-597C-4197-9128-E2D2189CC64E}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{E4C3711D-597C-4197-9128-E2D2189CC64E}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{E4C3711D-597C-4197-9128-E2D2189CC64E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E4C3711D-597C-4197-9128-E2D2189CC64E}.Release|Any CPU.Build.0 = Release|Any CPU
{E4C3711D-597C-4197-9128-E2D2189CC64E}.Release|iPhone.ActiveCfg = Release|Any CPU
{E4C3711D-597C-4197-9128-E2D2189CC64E}.Release|iPhone.Build.0 = Release|Any CPU
{E4C3711D-597C-4197-9128-E2D2189CC64E}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{E4C3711D-597C-4197-9128-E2D2189CC64E}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{3E8452CA-14A3-432E-8378-99EAC13E5EED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3E8452CA-14A3-432E-8378-99EAC13E5EED}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E8452CA-14A3-432E-8378-99EAC13E5EED}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{3E8452CA-14A3-432E-8378-99EAC13E5EED}.Debug|iPhone.Build.0 = Debug|Any CPU
{3E8452CA-14A3-432E-8378-99EAC13E5EED}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{3E8452CA-14A3-432E-8378-99EAC13E5EED}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{3E8452CA-14A3-432E-8378-99EAC13E5EED}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E8452CA-14A3-432E-8378-99EAC13E5EED}.Release|Any CPU.Build.0 = Release|Any CPU
{3E8452CA-14A3-432E-8378-99EAC13E5EED}.Release|iPhone.ActiveCfg = Release|Any CPU
{3E8452CA-14A3-432E-8378-99EAC13E5EED}.Release|iPhone.Build.0 = Release|Any CPU
{3E8452CA-14A3-432E-8378-99EAC13E5EED}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{3E8452CA-14A3-432E-8378-99EAC13E5EED}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{C2332CB0-EE05-46EE-8E3D-0047138B32EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C2332CB0-EE05-46EE-8E3D-0047138B32EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C2332CB0-EE05-46EE-8E3D-0047138B32EC}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{C2332CB0-EE05-46EE-8E3D-0047138B32EC}.Debug|iPhone.Build.0 = Debug|Any CPU
{C2332CB0-EE05-46EE-8E3D-0047138B32EC}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{C2332CB0-EE05-46EE-8E3D-0047138B32EC}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{C2332CB0-EE05-46EE-8E3D-0047138B32EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C2332CB0-EE05-46EE-8E3D-0047138B32EC}.Release|Any CPU.Build.0 = Release|Any CPU
{C2332CB0-EE05-46EE-8E3D-0047138B32EC}.Release|iPhone.ActiveCfg = Release|Any CPU
{C2332CB0-EE05-46EE-8E3D-0047138B32EC}.Release|iPhone.Build.0 = Release|Any CPU
{C2332CB0-EE05-46EE-8E3D-0047138B32EC}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{C2332CB0-EE05-46EE-8E3D-0047138B32EC}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -369,6 +413,10 @@ Global
{5E423494-7C7A-485E-8E84-A5CD11F7C504} = {4DB29E0A-3D0F-4CD5-AD58-3701BF3C23CC}
{6118BA67-8200-42C8-8A6D-B65E085E07A0} = {755410A3-91C0-4CD3-B234-1DEAE35F19DA}
{E7D0352B-16E1-4A89-8C29-ED119FF03316} = {6118BA67-8200-42C8-8A6D-B65E085E07A0}
{B5E9B3FC-1304-4A74-B0A9-607282AB2FD0} = {A143115C-F0CD-42A5-9DBB-31F4857D8729}
{E4C3711D-597C-4197-9128-E2D2189CC64E} = {B5E9B3FC-1304-4A74-B0A9-607282AB2FD0}
{3E8452CA-14A3-432E-8378-99EAC13E5EED} = {B5E9B3FC-1304-4A74-B0A9-607282AB2FD0}
{C2332CB0-EE05-46EE-8E3D-0047138B32EC} = {B5E9B3FC-1304-4A74-B0A9-607282AB2FD0}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B1F2E0DF-C651-48A3-83E3-3B77D34EC3A2}
Expand Down
36 changes: 34 additions & 2 deletions Source/Fluxor/DependencyInjection/FluxorOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using Fluxor.Extensions;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -14,6 +15,8 @@ public class FluxorOptions
internal AssemblyScanSettings[] AssembliesToScan { get; private set; } = Array.Empty<AssemblyScanSettings>();
internal Type[] TypesToScan { get; private set; } = Array.Empty<Type>();
internal Type[] MiddlewareTypes = Array.Empty<Type>();
internal StoreLifetime StoreLifetime { get; set; } = StoreLifetime.Scoped;

/// <summary>
/// Service collection for registering services
/// </summary>
Expand Down Expand Up @@ -53,6 +56,35 @@ public FluxorOptions(IServiceCollection services)
return this;
}

/// <summary>
/// The Store Lifetime that should be used when registering Fluxor features/reducers/effects/middleware
/// </summary>
/// <param name="lifecycle">the lifecycle to use</param>
/// <returns>Options</returns>
/// <remarks>
/// <list type="bullet">
/// <item>
/// <term>LifecycleEnum.Scoped</term>
/// <description>(default) Create a new instance for each new request</description>
/// </item>
/// <item>
/// <term>LifecycleEnum.Singleton</term>
/// <description>Create a new instance on first request and reuse for rest of application lifetime</description>
/// <para>
/// NOTE: indicating Singleton should be done only for exceptional cases.
/// For example, in MAUI/Blazor hybrid applications, the main MAUI application is a different scope then each BlazorWebView component
/// and state needs to be shared across all scopes of the application
/// </para>
/// <para>
/// This value should only be set once during the configuration of Fluxor
/// </para>
/// </remarks>
public FluxorOptions WithLifetime(StoreLifetime lifecycle)
{
StoreLifetime = lifecycle;
return this;
}

/// <summary>
/// Enables automatic discovery of features/effects/reducers
/// </summary>
Expand Down Expand Up @@ -89,7 +121,7 @@ public FluxorOptions AddMiddleware<TMiddleware>()
if (Array.IndexOf(MiddlewareTypes, typeof(TMiddleware)) > -1)
return this;

Services.AddScoped(typeof(TMiddleware));
Services.Add(typeof(TMiddleware), this);
Assembly assembly = typeof(TMiddleware).Assembly;
string @namespace = typeof(TMiddleware).Namespace;

Expand Down
8 changes: 8 additions & 0 deletions Source/Fluxor/DependencyInjection/LifecycleEnum.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Fluxor
{
public enum StoreLifetime
{
Scoped,
Singleton
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Fluxor.DependencyInjection;
using Fluxor.Extensions;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -31,7 +32,7 @@ public static class ServiceCollectionExtensions

// Register all middleware types with dependency injection
foreach (Type middlewareType in options.MiddlewareTypes)
services.AddScoped(middlewareType);
services.Add(middlewareType, options);

IEnumerable<AssemblyScanSettings> scanIncludeList = options.MiddlewareTypes
.Select(t => new AssemblyScanSettings(t.Assembly, t.Namespace));
Expand All @@ -42,10 +43,11 @@ public static class ServiceCollectionExtensions
assembliesToScan: options.AssembliesToScan,
typesToScan: options.TypesToScan,
scanIncludeList: scanIncludeList);
services.AddScoped(typeof(IState<>), typeof(State<>));
services.Add(typeof(IState<>), typeof(State<>), options);
services.AddTransient(typeof(IStateSelection<,>), typeof(StateSelection<,>));

return services;
}

}
}

0 comments on commit 97997c7

Please sign in to comment.