File tree Expand file tree Collapse file tree 5 files changed +27
-14
lines changed Expand file tree Collapse file tree 5 files changed +27
-14
lines changed Original file line number Diff line number Diff line change 1
1
namespace Counter ;
2
2
3
+ internal partial record Countable ( int Count , int Step )
4
+ {
5
+ public Countable Increment ( ) => this with
6
+ {
7
+ Count = Count + Step
8
+ } ;
9
+ }
10
+
3
11
internal partial record MainModel
4
12
{
5
- public IState < int > Count => State . Value ( this , ( ) => 0 ) ;
13
+ public IState < Countable > Countable => State . Value ( this , ( ) => new Countable ( 0 , 1 ) ) ;
6
14
7
- public IState < int > Step => State . Value ( this , ( ) => 1 ) ;
8
-
9
- public ValueTask IncrementCommand ( int Step )
10
- => Count . Update ( c => c + Step , CancellationToken . None ) ;
15
+ public ValueTask IncrementCommand ( )
16
+ => Countable . Update ( c => c ? . Increment ( ) , CancellationToken . None ) ;
11
17
}
Original file line number Diff line number Diff line change @@ -21,12 +21,12 @@ public MainPage()
21
21
. HorizontalAlignment ( HorizontalAlignment . Center )
22
22
. TextAlignment ( Microsoft . UI . Xaml . TextAlignment . Center )
23
23
. PlaceholderText ( "Step Size" )
24
- . Text ( x => x . Bind ( ( ) => vm . Step ) . TwoWay ( ) ) ,
24
+ . Text ( x => x . Bind ( ( ) => vm . Countable . Step ) . TwoWay ( ) ) ,
25
25
new TextBlock ( )
26
26
. Margin ( 12 )
27
27
. HorizontalAlignment ( HorizontalAlignment . Center )
28
28
. TextAlignment ( Microsoft . UI . Xaml . TextAlignment . Center )
29
- . Text ( ( ) => vm . Count , txt => $ "Counter: { txt } ") ,
29
+ . Text ( ( ) => vm . Countable . Count , txt => $ "Counter: { txt } ") ,
30
30
new Button ( )
31
31
. Margin ( 12 )
32
32
. HorizontalAlignment ( HorizontalAlignment . Center )
Original file line number Diff line number Diff line change
1
+ namespace Counter ;
2
+
3
+ internal partial record Countable ( int Count , int Step )
4
+ {
5
+ public Countable Increment ( ) => this with
6
+ {
7
+ Count = Count + Step
8
+ } ;
9
+ }
Original file line number Diff line number Diff line change @@ -2,10 +2,8 @@ namespace Counter;
2
2
3
3
internal partial record MainModel
4
4
{
5
- public IState < int > Count => State . Value ( this , ( ) => 0 ) ;
5
+ public IState < Countable > Countable => State . Value ( this , ( ) => new Countable ( 0 , 1 ) ) ;
6
6
7
- public IState < int > Step => State . Value ( this , ( ) => 1 ) ;
8
-
9
- public ValueTask IncrementCommand ( int Step )
10
- => Count . Update ( c => c + Step , CancellationToken . None ) ;
7
+ public ValueTask IncrementCommand ( ) =>
8
+ Countable . Update ( c => c ? . Increment ( ) , CancellationToken . None ) ;
11
9
}
Original file line number Diff line number Diff line change 19
19
Margin=" 12"
20
20
HorizontalAlignment=" Center"
21
21
PlaceholderText=" Step Size"
22
- Text=" {Binding Step, Mode=TwoWay}"
22
+ Text=" {Binding Countable. Step, Mode=TwoWay}"
23
23
TextAlignment=" Center" />
24
24
25
25
<TextBlock
26
26
Margin=" 12"
27
27
HorizontalAlignment=" Center"
28
28
TextAlignment=" Center" >
29
- <Run Text =" Counter: " /><Run Text =" {Binding Count}" />
29
+ <Run Text =" Counter: " /><Run Text =" {Binding Countable. Count}" />
30
30
</TextBlock >
31
31
32
32
<Button
You can’t perform that action at this time.
0 commit comments