@@ -36,14 +36,14 @@ You will need to follow the following steps to create your own Redux Store:
36361 . Create` State ` definition
3737
3838``` csharp
39- public class RootState
39+ public record RootState
4040{
4141public string CurrentPage {get ;set ; }= string .Empty ;
4242public ImmutableArray <string >Pages {get ;set ; }= ImmutableArray <string >.Empty ;
4343}
4444```
4545
46- Each State should immutable. That's why we prefer to use immutable types for each property of the State.
46+ Each State shouldbe immutable. That's why we prefer to use immutable types for each property of the State.
4747
48482 . Create` Action ` definitions
4949
@@ -68,23 +68,24 @@ public static class Reducers
6868return new List <On <RootState >>
6969 {
7070On <NavigateAction ,RootState >(
71- (state ,action )=> state . With ( new {Pages = state .Pages .Add (action .PageName ) })
71+ (state ,action )=> state with {Pages = state .Pages .Add (action .PageName ) }
7272 ),
7373On <GoBackAction ,RootState >(
7474state =>
7575 {
7676var newPages = state .Pages .RemoveAt (state .Pages .Length - 1 );
77- return state .With (new {
77+
78+ return state with {
7879CurrentPage = newPages .LastOrDefault (),
7980Pages = newPages
80- }) ;
81+ };
8182 }
8283 ),
8384On <ResetAction ,RootState >(
84- state => state . With ( new {
85+ state => state with {
8586CurrentPage = string .Empty ,
8687Pages = ImmutableArray <string >.Empty
87- })
88+ }
8889 )
8990 };
9091 }
@@ -158,23 +159,24 @@ You can define a list of `On` functions where at least one action can be trigger
158159return new List <On <RootState >>
159160{
160161On <NavigateAction ,RootState >(
161- (state ,action )=> state . With ( new {Pages = state .Pages .Add (action .PageName ) })
162+ (state ,action )=> state with {Pages = state .Pages .Add (action .PageName ) }
162163 ),
163164On <GoBackAction ,RootState >(
164165state =>
165166 {
166167var newPages = state .Pages .RemoveAt (state .Pages .Length - 1 );
167- return state .With (new {
168+
169+ return state with {
168170CurrentPage = newPages .LastOrDefault (),
169171Pages = newPages
170- }) ;
172+ };
171173 }
172174 ),
173175On <ResetAction ,RootState >(
174- state => state . With ( new {
176+ state => state with {
175177CurrentPage = string .Empty ,
176178Pages = ImmutableArray <string >.Empty
177- })
179+ }
178180 )
179181};
180182```
@@ -195,8 +197,8 @@ First you need to create a new state lens for feature/nested states:
195197public static IEnumerable < On < RootState >> GetReducers ()
196198{
197199return CreateSubReducers (SelectCounterState )
198- .On <IncrementAction >(state => state . With ( new {Count = state .Count + 1 }) )
199- .On <DecrementAction >(state => state . With ( new {Count = state .Count - 1 }) )
200+ .On <IncrementAction >(state => state with {Count = state .Count + 1 })
201+ .On <DecrementAction >(state => state with {Count = state .Count - 1 })
200202 .ToList ();
201203}
202204```
@@ -532,7 +534,7 @@ When dealing with entities, you often repeat the same process to add, update and
5325341 . Start creating an` EntityState ` and an` EntityAdapter `
533535
534536``` csharp
535- public class TodoItemEntityState :EntityState <int ,TodoItem >
537+ public record TodoItemEntityState :EntityState <int ,TodoItem >
536538{
537539}
538540
@@ -545,7 +547,7 @@ public static class Entities
5455472 . Use the` EntityState ` in your state
546548
547549``` csharp
548- public class TodoListState
550+ public record TodoListState
549551{
550552public TodoItemEntityState Items {get ;set ; }
551553public TodoFilter Filter {get ;set ; }
@@ -558,10 +560,10 @@ public class TodoListState
558560On <CompleteTodoItemAction ,TodoListState >(
559561 (state ,action )=>
560562 {
561- return state . With ( new
563+ return state with
562564 {
563565Items = TodoItemAdapter .UpsertOne (new {action .Id ,Completed = true },state .Items )
564- }) ;
566+ };
565567 }
566568)
567569```