Skip to content

Commit

Permalink
Prepare dependencies a single time when creating Store.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrandonw committed Jan 5, 2024
1 parent 8e3ff3d commit 2787873
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-clocks",
"state" : {
"revision" : "d1fd837326aa719bee979bdde1f53cd5797443eb",
"version" : "1.0.0"
"revision" : "a8421d68068d8f45fbceb418fbf22c5dad4afd33",
"version" : "1.0.2"
}
},
{
Expand Down Expand Up @@ -149,8 +149,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swiftui-navigation.git",
"state" : {
"revision" : "a3aa5d46e8bf174d773d23b030f1c103999398ac",
"version" : "1.1.0"
"revision" : "78f9d72cf667adb47e2040aa373185c88c63f0dc",
"version" : "1.2.0"
}
},
{
Expand Down
7 changes: 4 additions & 3 deletions Sources/ComposableArchitecture/Store.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,13 @@ public final class Store<State, Action> {
withDependencies prepareDependencies: ((inout DependencyValues) -> Void)? = nil
) where R.State == State, R.Action == Action {
if let prepareDependencies = prepareDependencies {
let (initialState, reducer) = withDependencies(prepareDependencies) {
(initialState(), reducer())
let (initialState, reducer, dependencies) = withDependencies(prepareDependencies) {
@Dependency(\.self) var dependencies
return (initialState(), reducer(), dependencies)
}
self.init(
initialState: initialState,
reducer: reducer.transformDependency(\.self, transform: prepareDependencies)
reducer: reducer.dependency(\.self, dependencies)
)
} else {
self.init(
Expand Down

0 comments on commit 2787873

Please sign in to comment.