Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryu0118 authored Sep 19, 2023
1 parent f15067f commit 8bf3d06
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ let package = Package(
```

## Usage
#### Basic Usage
### Basic Usage
```Swift
struct MyReducer: ReducerProtocol {
enum Action {
Expand Down Expand Up @@ -73,7 +73,7 @@ struct MyView: View {
}
```

#### ReducerState
### ReducerState

Use ReducerState if you want to keep the state only in the Reducer.
ReducerState is also effective to improve performance because the View is not updated even if the value is changed.
Expand Down Expand Up @@ -129,7 +129,7 @@ struct MyView: View {
}
```

#### ReducerAction
### ReducerAction

If there are Actions that you do not want to expose to View, ReducerAction is effective.
This is the sample code:
Expand Down Expand Up @@ -190,7 +190,7 @@ struct MyView: View {
}
```

#### Pullback Action
### Pullback Action

If you want to send the Action of the child Reducer to the parent Reducer, use pullback.
This is the sample code.
Expand Down Expand Up @@ -244,3 +244,18 @@ struct ChildReducer: ReducerProtocol {
}
}
```

### Testing
You can write a test like this.
```Swift
let testStore = TestView().testStore(states: .init())
await testStore.send(.increment) {
$0.count = 1
}

let testStore = TestView().testStore(states: .init())
await testStore.send(.send)
await testStore.receive(.increment) {
$0.count = 1
}
```

0 comments on commit 8bf3d06

Please sign in to comment.