Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,30 @@ Here are some basic examples of how to use the library:

### Setup

Create your domain objects

```csharp
// domain.cs

public class TestState
{
public required Guid Id { get; set; }
public string? Test { get; set; }
}

```

Add the aggregate to the service collection

```csharp
// program.cs

using StreamWave;
using StreamWave.EntityFramework;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddAggregate<TestState, Guid>(() => new TestState() { Id = Guid.NewGuid() })
builder.Services.AddAggregate<TestState, Guid>((id) => new TestState() { Id = id })
.WithEntityFramework<TestContext, TestState, Guid>()
.WithApplier<TestEvent>((s, e) =>
{
Expand All @@ -67,13 +82,14 @@ builder.Services.AddAggregate<TestState, Guid>(() => new TestState() { Id = Gui

```csharp

public Task HandleAsync(IAggregate<TestState, Guid> aggregate, Guid id)
public async Task HandleAsync(IAggregateManager<TestState, Guid> manager, Guid id)
{
aggregate.LoadAsync(id);
var aggregate = manager.LoadAsync(id);

aggregate.Apply(new TestEvent("Update"));
}

await manager.SaveAsync(aggregate);
}

```

Expand Down
9 changes: 8 additions & 1 deletion StreamWave.sln
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StreamWave.EntityFramework.
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "example", "example", "{40B48187-5A59-4A8B-AA36-8E9C33278F0A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleApp", "examples\SampleApp\SampleApp.csproj", "{E81E8206-445E-4009-ADA6-850370A77951}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleApp", "examples\SampleApp\SampleApp.csproj", "{E81E8206-445E-4009-ADA6-850370A77951}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{84700FAC-774E-4E46-A3E3-3AD45672C938}"
ProjectSection(SolutionItems) = preProject
docs\getting-started.md = docs\getting-started.md
docs\introduction.md = docs\introduction.md
docs\toc.yml = docs\toc.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
15 changes: 14 additions & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
# Getting Started
# Getting Started

To get started with StreamWave in your .NET Core project follow these steps:

## 1. Installation

Add StreamWave to your project via Nuget Package Manager:

```bash
dotnet add package StreamWave
```

## 2. Create your domain objects

8 changes: 7 additions & 1 deletion docs/introduction.md
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
# Introduction
# Introduction

## StreamWave

StreamWave is an aggregate root library designed for streaming environments, aimed at addressing the dual write problem by decoupling the domain model from the event stream. It allows easy integration with .NET Core projects, providing a streamlined approach to managing aggregates and event sourcing. The library offers seamless setup and configuration, ensuring efficient handling of state changes and event applications. Contributions to the project are welcome, and it is licensed under the MIT License.

For more details, visit the [StreamWave GitHub repository](https://github.com/pmdevers/StreamWave).
1 change: 1 addition & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<None Include="..\..\assets\$(PackageIcon)">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
<Visible>false</Visible>
</None>
<None Include="..\..\README.md">
<Pack>True</Pack>
Expand Down
5 changes: 3 additions & 2 deletions src/StreamWave/Aggregate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ ValidateStateDelegate<TState> validator
_version++;
_createdOn ??= e.OccurredOn;
_lastModiefiedOn = e.OccurredOn;
return _applier(state, e);
return _applier(state, e.Event);
}));

runner.Wait();


}

public TId Id { get; private set; }
Expand Down