Skip to content

Commit

Permalink
Make ReduxDevTools DEBUG mode only
Browse files Browse the repository at this point in the history
  • Loading branch information
mrpmorris committed Mar 14, 2022
1 parent afbf57d commit 0e6606c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 27 deletions.
24 changes: 20 additions & 4 deletions Tutorials/02-Blazor/02D-ReduxDevToolsTutorial/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,30 @@

![](./../../../images/redux-dev-tools.jpg)

**NOTE:** ReduxDevTools allows the user to alter the state of your store
directly. This might be a security flaw, so you should only reference
this package in `Debug` builds.

To enable Fluxor integration, follow these steps
1. Add the [Fluxor.Blazor.Web.ReduxDevTools][FluxorReduxDevToolsLink] nuget package to your project.
1. Add the [Fluxor.Blazor.Web.ReduxDevTools][FluxorReduxDevToolsLink] nuget package
to your project. Make sure you make it conditional on `DEBUG` mode.

```
<ItemGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PackageReference Include="Fluxor.Blazor.Web.ReduxDevTools\Fluxor.Blazor.Web.ReduxDevTools" Version="....." />
</ItemGroup>
```

2. Use the `UseReduxDevTools` extension on the Fluxor options.

```c#
services.AddFluxor(o => o
.ScanAssemblies(typeof(SomeType).Assembly)
.UseReduxDevTools());
services.AddFluxor(o =>
{
o.ScanAssemblies(typeof(SomeType).Assembly);
#if DEBUG
o.UseReduxDevTools();
#ENDIF
});
```

3. When you run your application, click the icon for the Redux Dev Tools extension.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<LangVersion>9</LangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<LangVersion>9</LangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.1" PrivateAssets="all" />
<PackageReference Include="System.Net.Http.Json" Version="3.2.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\Source\Fluxor.Blazor.Web.ReduxDevTools\Fluxor.Blazor.Web.ReduxDevTools.csproj" />
<ProjectReference Include="..\..\..\..\..\Source\Fluxor.Blazor.Web\Fluxor.Blazor.Web.csproj" />
<ProjectReference Include="..\..\..\..\..\Source\Fluxor\Fluxor.csproj" />
<ProjectReference Include="..\Shared\FluxorBlazorWeb.ReduxDevToolsTutorial.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.1" PrivateAssets="all" />
<PackageReference Include="System.Net.Http.Json" Version="3.2.1" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<ProjectReference Include="..\..\..\..\..\Source\Fluxor.Blazor.Web.ReduxDevTools\Fluxor.Blazor.Web.ReduxDevTools.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\Source\Fluxor.Blazor.Web\Fluxor.Blazor.Web.csproj" />
<ProjectReference Include="..\..\..\..\..\Source\Fluxor\Fluxor.csproj" />
<ProjectReference Include="..\Shared\FluxorBlazorWeb.ReduxDevToolsTutorial.Shared.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ public static async Task Main(string[] args)

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

builder.Services.AddFluxor(o => o
.ScanAssemblies(typeof(Program).Assembly)
.UseReduxDevTools(rdt =>
builder.Services.AddFluxor(o =>
{
o.ScanAssemblies(typeof(Program).Assembly);
#if DEBUG
o.UseReduxDevTools(rdt =>
{
rdt.Name = "Fluxor ReduxDevTools sample";

Expand All @@ -40,9 +42,10 @@ public static async Task Main(string[] args)
PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase
}
);
})
);
});
#endif
});
await builder.Build().RunAsync();
}
}
}
}

0 comments on commit 0e6606c

Please sign in to comment.