Skip to content

Commit

Permalink
Replace deprecated viewStore with store (#3341)
Browse files Browse the repository at this point in the history
* [FIX] Replace deprecated viewStore with store

* [FIX] Replace deprecated viewStore with store in Article

* [TEST] Match the changed view store message with the test message

* [TEST] Match the changed view store message with the test message
  • Loading branch information
qwerty3345 committed Sep 5, 2024
1 parent 0352611 commit 71f8291
Show file tree
Hide file tree
Showing 15 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,13 @@ class FeatureViewController: UIViewController {
}

@objc private func incrementButtonTapped() {
self.viewStore.send(.incrementButtonTapped)
self.store.send(.incrementButtonTapped)
}
@objc private func decrementButtonTapped() {
self.viewStore.send(.decrementButtonTapped)
self.store.send(.decrementButtonTapped)
}
@objc private func factButtonTapped() {
self.viewStore.send(.numberFactButtonTapped)
self.store.send(.numberFactButtonTapped)
}
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,10 @@ This greatly reduces the bandwidth of actions being sent into the system so that
incurring unnecessary costs for sending actions.

Another example that comes up often is sliders. If done in the most direct way, by deriving a
binding from the view store to hand to a `Slider`:
binding from the store to hand to a `Slider`:

```swift
Slider(value: viewStore.$opacity, in: 0...1)
Slider(value: store.$opacity, in: 0...1)
```

This will send an action into the system for every little change to the slider, which can be dozens
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

@Step {
Add a button to each row of the contacts list in order to send the `deleteButtonTapped`
action to the view store.
action to the store.

@Code(name: "ContactsFeatures.swift", file: 02-02-01-code-0007.swift)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public struct _ForEachReducer<
associated effect before an element is removed, especially if it is a long-living effect.
• This action was sent to the store while its state contained no element at this ID. To \
fix this make sure that actions for this reducer can only be sent from a view store when \
fix this make sure that actions for this reducer can only be sent from a store when \
its state contains an element at this id. In SwiftUI applications, use "ForEachStore".
""",
fileID: fileID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public struct _IfCaseLetReducer<Parent: Reducer, Child: Reducer>: Reducer {
before child state changes to another case, especially if it is a long-living effect.
• This action was sent to the store while state was another case. Make sure that actions \
for this reducer can only be sent from a view store when state is set to the appropriate \
for this reducer can only be sent from a store when state is set to the appropriate \
case. In SwiftUI applications, use "SwitchStore".
""",
fileID: fileID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public struct _IfLetReducer<Parent: Reducer, Child: Reducer>: Reducer {
before child state becomes "nil", especially if it is a long-living effect.
• This action was sent to the store while state was "nil". Make sure that actions for this \
reducer can only be sent from a view store when state is non-"nil". In SwiftUI \
reducer can only be sent from a store when state is non-"nil". In SwiftUI \
applications, use "IfLetStore".
""",
fileID: fileID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ public struct _PresentationReducer<Base: Reducer, Destination: Reducer>: Reducer
destination reducers can handle their actions while their state is still present.
• This action was sent to the store while destination state was "nil". Make sure that \
actions for this reducer can only be sent from a view store when state is present, or \
actions for this reducer can only be sent from a store when state is present, or \
from effects that start from this reducer. In SwiftUI applications, use a Composable \
Architecture view modifier like "sheet(store:…)".
""",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public struct Scope<ParentState, ParentAction, Child: Reducer>: Reducer {
before child state changes to another case, especially if it is a long-living effect.
• This action was sent to the store while state was another case. Make sure that actions \
for this reducer can only be sent from a view store when state is set to the appropriate \
for this reducer can only be sent from a store when state is set to the appropriate \
case. In SwiftUI applications, use "SwitchStore".
""",
fileID: fileID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ public struct _StackReducer<Base: Reducer, Destination: Reducer>: Reducer {
associated effect before an element is removed, especially if it is a long-living effect.
• This action was sent to the store while its state contained no element at this ID. To \
fix this make sure that actions for this reducer can only be sent from a view store when \
fix this make sure that actions for this reducer can only be sent from a store when \
its state contains an element at this id. In SwiftUI applications, use \
"NavigationStack.init(path:)" with a binding to a store.
""",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ final class ForEachReducerTests: BaseTCATestCase {
associated effect before an element is removed, especially if it is a long-living effect.
• This action was sent to the store while its state contained no element at this ID. To \
fix this make sure that actions for this reducer can only be sent from a view store when \
fix this make sure that actions for this reducer can only be sent from a store when \
its state contains an element at this id. In SwiftUI applications, use "ForEachStore".
"""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ final class IfCaseLetReducerTests: BaseTCATestCase {
before child state changes to another case, especially if it is a long-living effect.
• This action was sent to the store while state was another case. Make sure that actions \
for this reducer can only be sent from a view store when state is set to the appropriate \
for this reducer can only be sent from a store when state is set to the appropriate \
case. In SwiftUI applications, use "SwitchStore".
"""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class IfLetReducerTests: BaseTCATestCase {
before child state becomes "nil", especially if it is a long-living effect.
• This action was sent to the store while state was "nil". Make sure that actions for \
this reducer can only be sent from a view store when state is non-"nil". In SwiftUI \
this reducer can only be sent from a store when state is non-"nil". In SwiftUI \
applications, use "IfLetStore".
"""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1739,7 +1739,7 @@ final class PresentationReducerTests: BaseTCATestCase {
destination reducers can handle their actions while their state is still present.
• This action was sent to the store while destination state was "nil". Make sure that \
actions for this reducer can only be sent from a view store when state is present, or \
actions for this reducer can only be sent from a store when state is present, or \
from effects that start from this reducer. In SwiftUI applications, use a Composable \
Architecture view modifier like "sheet(store:…)".
"""
Expand Down Expand Up @@ -1796,7 +1796,7 @@ final class PresentationReducerTests: BaseTCATestCase {
destination reducers can handle their actions while their state is still present.
• This action was sent to the store while destination state was "nil". Make sure that \
actions for this reducer can only be sent from a view store when state is present, or \
actions for this reducer can only be sent from a store when state is present, or \
from effects that start from this reducer. In SwiftUI applications, use a Composable \
Architecture view modifier like "sheet(store:…)".
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ final class StackReducerTests: BaseTCATestCase {
associated effect before an element is removed, especially if it is a long-living effect.
• This action was sent to the store while its state contained no element at this ID. To \
fix this make sure that actions for this reducer can only be sent from a view store when \
fix this make sure that actions for this reducer can only be sent from a store when \
its state contains an element at this id. In SwiftUI applications, use \
"NavigationStack.init(path:)" with a binding to a store.
"""
Expand Down
2 changes: 1 addition & 1 deletion Tests/ComposableArchitectureTests/ScopeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ final class ScopeTests: BaseTCATestCase {
before child state changes to another case, especially if it is a long-living effect.
• This action was sent to the store while state was another case. Make sure that actions \
for this reducer can only be sent from a view store when state is set to the appropriate \
for this reducer can only be sent from a store when state is set to the appropriate \
case. In SwiftUI applications, use "SwitchStore".
"""
}
Expand Down

0 comments on commit 71f8291

Please sign in to comment.