Skip to main content

Setup Blazor Project

📦 Installation & Setup​

Install-Package StatePulse.Net

dotnet add package StatePulse.Net

Add to Program.cs:

builder.Services.AddStatePulseServices(o => {});

Create StatePulse common folder structure.

/Pulses/
/Pulses/Counter <- Feature
/Pulses/Counter/Actions
/Pulses/Counter/Effects
/Pulses/Counter/Effects/Validators
/Pulses/Counter/Reducers
/Pulses/Counter/Stores

This structure is complete and very common pattern.

Add Services​

There are 2 ways to add services for StatePulse.

Scan Assmblies​

The easiest way is to scan whatever assembly you have pulses in.

program.cs
builder.Services.AddStatePulseServices(o =>
{
o.ScanAssemblies = new Type[] { typeof(Program) };
});

Manual Registering​

StatePulse provide extension methods to add type of services and you MUST use them otherwise you face issues.

program.cs
builder.Services.AddStatePulseAction<IAction>();
builder.Services.AddStatePulseEffect<IEffect>();
builder.Services.AddStatePulseEffectValidator<IEffectValidator>();
builder.Services.AddStatePulseReducer<IReducer>();
builder.Services.AddStatePulseStateFeature<IStateFeature>();

Note: you must manually register all services during unit test... the assembly scan doesn't get along well with unit testing.