Skip to content

Commit a1eaef4

Browse files
committed
feat: Update documentation and version to v2.0.0
- Updated version badge in persistence.html, render-modes.html, and state-management.html to v2.0.0. - Enhanced navigation sections in documentation for Async Helpers, Advanced Features, Sync & Collaboration, and Extensibility. - Added detailed sections for Cross-Tab Synchronization and Server Synchronization (SignalR) in persistence.html. - Improved feature compatibility matrix in render-modes.html to clarify support across Blazor render modes. - Expanded state management documentation with new sections for Optimistic Updates, Undo/Redo History, Query System, Immer-Style Updates, and Redux-Style Actions. - Updated project version in EasyAppDev.Blazor.Store.csproj from v3.0.0 to v2.0.0.
1 parent df43eac commit a1eaef4

22 files changed

Lines changed: 1747 additions & 343 deletions

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
</a>
1414
</div>
1515

16+
> **Upgrading from v1.x?** See [Breaking Changes in v2.0.0](#breaking-changes-in-v300) for migration guide.
17+
1618
---
1719

1820
## Why This Library?
@@ -94,6 +96,7 @@ That's it. State updates automatically propagate to all subscribed components.
9496
14. [Middleware](#middleware)
9597
15. [Blazor Render Modes](#blazor-render-modes)
9698
16. [API Reference](#api-reference)
99+
17. [Breaking Changes in v2.0.0](#breaking-changes-in-v300)
97100

98101
---
99102

@@ -911,6 +914,70 @@ store
911914

912915
---
913916

917+
## Breaking Changes in v2.0.0
918+
919+
This major release introduces powerful new features but includes breaking changes from v1.x:
920+
921+
### Middleware Interface
922+
923+
The `IMiddleware<TState>` interface now receives both previous and new state in `OnAfterUpdateAsync`:
924+
925+
```csharp
926+
// Before (v1.x)
927+
Task OnAfterUpdateAsync(TState newState, string? action);
928+
929+
// After (v2.0)
930+
Task OnAfterUpdateAsync(TState previousState, TState newState, string? action);
931+
```
932+
933+
**Migration:** Update your middleware implementations to accept the additional `previousState` parameter.
934+
935+
### Optimistic Updates
936+
937+
Optimistic updates now use dedicated extension methods instead of manual patterns:
938+
939+
```csharp
940+
// Before (v1.x) - Manual rollback pattern
941+
var original = store.GetState();
942+
await store.UpdateAsync(s => s.RemoveItem(id));
943+
try { await api.DeleteAsync(id); }
944+
catch { await store.UpdateAsync(_ => original); throw; }
945+
946+
// After (v2.0) - Built-in support
947+
await store.UpdateOptimistic(
948+
s => s.RemoveItem(id),
949+
async _ => await api.DeleteAsync(id),
950+
(s, error) => s.RestoreItem(id)
951+
);
952+
```
953+
954+
**Migration:** Replace manual try/catch rollback patterns with `UpdateOptimistic()`.
955+
956+
### Plugin System
957+
958+
Plugin hooks now receive both previous and new state:
959+
960+
```csharp
961+
// Before (v1.x)
962+
public override Task OnAfterUpdateAsync(AppState newState, string action);
963+
964+
// After (v2.0)
965+
public override Task OnAfterUpdateAsync(AppState previousState, AppState newState, string action);
966+
```
967+
968+
**Migration:** Update plugin `OnAfterUpdateAsync` overrides to include `previousState` parameter.
969+
970+
### New Features (Non-Breaking)
971+
972+
- **Query System**: TanStack Query-inspired data fetching with `IQueryClient`
973+
- **Immer-Style Updates**: Clean syntax with `ProduceAsync()` and draft operations
974+
- **Undo/Redo History**: Full history stack with `IStoreHistory<T>`
975+
- **Cross-Tab Sync**: Real-time sync with `WithTabSync()`
976+
- **Server Sync**: SignalR collaboration with `WithServerSync()`
977+
- **Security**: `[SensitiveData]` attribute and `IStateValidator<T>`
978+
979+
---
980+
914981
## Common Gotchas
915982

916983
1. **Always use `with`**: `state with { X = 1 }` not `state.X = 1`

0 commit comments

Comments
 (0)