Skip to content

Commit a796124

Browse files
authored
Merge pull request #3 from ptu14/siplify-example-component
refactor: simplify example component
2 parents d366987 + cb1f36f commit a796124

File tree

2 files changed

+18
-39
lines changed

2 files changed

+18
-39
lines changed

projects/angular-redux-demo/src/app/app.component.ts

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,19 @@
11
import { Component } from '@angular/core'
2-
import {injectSelector, injectDispatch} from "@reduxjs/angular-redux";
2+
import { injectSelector, injectDispatch } from "@reduxjs/angular-redux";
33
import { decrement, increment } from './store/counter-slice'
44
import { RootState } from './store'
55

66
@Component({
77
selector: 'app-root',
88
standalone: true,
9-
imports: [],
109
template: `
11-
<div>
12-
<div>
13-
<button
14-
aria-label="Increment value"
15-
(click)="dispatch(increment())"
16-
>
17-
Increment
18-
</button>
19-
<span>{{ count() }}</span>
20-
<button
21-
aria-label="Decrement value"
22-
(click)="dispatch(decrement())"
23-
>
24-
Decrement
25-
</button>
26-
</div>
27-
</div>
10+
<button (click)="dispatch(increment())">
11+
Increment
12+
</button>
13+
<span>{{ count() }}</span>
14+
<button (click)="dispatch(decrement())">
15+
Decrement
16+
</button>
2817
`
2918
})
3019
export class AppComponent {

projects/angular-redux/README.md

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,21 @@ The following Angular component works as-expected:
3737

3838
```angular-ts
3939
import { Component } from '@angular/core'
40-
import {injectSelector, injectDispatch} from "@reduxjs/angular-redux";
41-
import { decrement, increment, RootState } from './store/counter-slice'
40+
import { injectSelector, injectDispatch } from "@reduxjs/angular-redux";
41+
import { decrement, increment } from './store/counter-slice'
42+
import { RootState } from './store'
4243
4344
@Component({
4445
selector: 'app-root',
4546
standalone: true,
46-
imports: [],
4747
template: `
48-
<div>
49-
<div>
50-
<button
51-
aria-label="Increment value"
52-
(click)="dispatch(increment())"
53-
>
54-
Increment
55-
</button>
56-
<span>{{ count() }}</span>
57-
<button
58-
aria-label="Decrement value"
59-
(click)="dispatch(decrement())"
60-
>
61-
Decrement
62-
</button>
63-
</div>
64-
</div>
48+
<button (click)="dispatch(increment())">
49+
Increment
50+
</button>
51+
<span>{{ count() }}</span>
52+
<button (click)="dispatch(decrement())">
53+
Decrement
54+
</button>
6555
`
6656
})
6757
export class AppComponent {

0 commit comments

Comments
 (0)