Skip to content

Commit f6128b3

Browse files
committed
docs: update code embed to Angular example
1 parent 33e626a commit f6128b3

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

Diff for: docs/tutorials/quick-start.md

+13-8
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ bootstrapApplication(AppComponent, {
7979

8080
### Create a Redux State Slice
8181

82-
Add a new file named `src/features/counter/counterSlice.ts`. In that file, import the `createSlice` API from Redux Toolkit.
82+
Add a new file named `src/features/counter/counter-slice.ts`. In that file, import the `createSlice` API from Redux Toolkit.
8383

8484
Creating a slice requires a string name to identify the slice, an initial state value, and one or more reducer functions to define how the state can be updated. Once a slice is created, we can export the generated Redux action creators and the reducer function for the whole slice.
8585

8686
Redux requires that [we write all state updates immutably, by making copies of data and updating the copies](https://redux.js.org/tutorials/fundamentals/part-2-concepts-data-flow#immutability). However, Redux Toolkit's `createSlice` and `createReducer` APIs use [Immer](https://immerjs.github.io/immer/) inside to allow us to [write "mutating" update logic that becomes correct immutable updates](https://redux.js.org/tutorials/fundamentals/part-8-modern-redux#immutable-updates-with-immer).
8787

88-
```js title="features/counter/counterSlice.ts"
88+
```js title="features/counter/counter-slice.ts"
8989
import { createSlice } from "@reduxjs/toolkit";
9090

9191
export const counterSlice = createSlice({
@@ -124,7 +124,12 @@ Next, we need to import the reducer function from the counter slice and add it t
124124
```js title="app/store.ts"
125125
import { configureStore } from "@reduxjs/toolkit";
126126
// highlight-next-line
127-
import counterReducer from "../features/counter/counterSlice";
127+
import counterReducer from "./features/counter/counter-slice";
128+
129+
// Infer the `RootState` and `AppDispatch` types from the store itself
130+
export type RootState = ReturnType<typeof store.getState>;
131+
// Inferred type: {counter: CounterState}
132+
export type AppDispatch = typeof store.dispatch;
128133

129134
export default configureStore({
130135
reducer: {
@@ -141,8 +146,8 @@ Now we can use the Angular Redux inject functions to let Angular components inte
141146
```typescript title="features/counter/counter.component.ts"
142147
import { Component } from "@angular/core";
143148
import { injectSelector, injectDispatch } from "@reduxjs/angular-redux";
144-
import { decrement, increment } from "./store/counter-slice";
145-
import { RootState } from "./store";
149+
import { RootState } from "../../store";
150+
import { decrement, increment } from "./counter-slice";
146151

147152
@Component({
148153
selector: "app-counter",
@@ -191,12 +196,12 @@ That was a brief overview of how to set up and use Redux Toolkit with Angular. R
191196

192197
### Full Counter App Example
193198

194-
Here's the complete Counter application as a running CodeSandbox:
199+
Here's the complete Counter application as a running StackBlitz:
195200

196201
<iframe
197202
class="codesandbox"
198-
src="https://codesandbox.io/embed/github/reduxjs/redux-essentials-counter-example/tree/master/?fontsize=14&hidenavigation=1&module=%2Fsrc%2Ffeatures%2Fcounter%2FcounterSlice.js&theme=dark&runonclick=1"
199-
title="redux-essentials-example"
203+
src="https://stackblitz.com/github/reduxjs/angular-redux-essentials-counter-example/tree/main?template=node&ctl=1&embed=1&file=src%2Fapp%2Ffeatures%2Fcounter%2Fcounter-slice.ts&hideNavigation=1&view=preview"
204+
title="angular-redux-essentials-example"
200205
allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
201206
sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
202207
></iframe>

Diff for: projects/angular-redux-demo/src/app/store/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ export const store = configureStore({
99

1010
// Infer the `RootState` and `AppDispatch` types from the store itself
1111
export type RootState = ReturnType<typeof store.getState>;
12-
// Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState}
12+
// Inferred type: {counter: CounterState}
1313
export type AppDispatch = typeof store.dispatch;

0 commit comments

Comments
 (0)