Skip to content

Add Store.init that takes reducer builder #2087

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions Examples/CaseStudies/SwiftUICaseStudies/00-RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,9 @@ struct RootView: View {
struct RootView_Previews: PreviewProvider {
static var previews: some View {
RootView(
store: Store(
initialState: Root.State(),
reducer: Root()
)
store: Store(initialState: Root.State()) {
Root()
}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,9 @@ struct AlertAndConfirmationDialog_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
AlertAndConfirmationDialogView(
store: Store(
initialState: AlertAndConfirmationDialog.State(),
reducer: AlertAndConfirmationDialog()
)
store: Store(initialState: AlertAndConfirmationDialog.State()) {
AlertAndConfirmationDialog()
}
Comment on lines +131 to +133
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usage is generally shorter, which is kinda nice.

)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,17 @@ struct AnimationsView_Previews: PreviewProvider {
Group {
NavigationView {
AnimationsView(
store: Store(
initialState: Animations.State(),
reducer: Animations()
)
store: Store(initialState: Animations.State()) {
Animations()
}
)
}

NavigationView {
AnimationsView(
store: Store(
initialState: Animations.State(),
reducer: Animations()
)
store: Store(initialState: Animations.State()) {
Animations()
}
)
}
.environment(\.colorScheme, .dark)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,9 @@ struct BindingBasicsView_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
BindingBasicsView(
store: Store(
initialState: BindingBasics.State(),
reducer: BindingBasics()
)
store: Store(initialState: BindingBasics.State()) {
BindingBasics()
}
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,9 @@ struct BindingFormView_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
BindingFormView(
store: Store(
initialState: BindingForm.State(),
reducer: BindingForm()
)
store: Store(initialState: BindingForm.State()) {
BindingForm()
}
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ struct TwoCountersView_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
TwoCountersView(
store: Store(
initialState: TwoCounters.State(),
reducer: TwoCounters()
)
store: Store(initialState: TwoCounters.State()) {
TwoCounters()
}
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,9 @@ struct CounterView_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
CounterDemoView(
store: Store(
initialState: Counter.State(),
reducer: Counter()
)
store: Store(initialState: Counter.State()) {
Counter()
}
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,9 @@ struct FocusDemo_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
FocusDemoView(
store: Store(
initialState: FocusDemo.State(),
reducer: FocusDemo()
)
store: Store(initialState: FocusDemo.State()) {
FocusDemo()
}
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,19 @@ struct OptionalBasicsView_Previews: PreviewProvider {
Group {
NavigationView {
OptionalBasicsView(
store: Store(
initialState: OptionalBasics.State(),
reducer: OptionalBasics()
)
store: Store(initialState: OptionalBasics.State()) {
OptionalBasics()
}
)
}

NavigationView {
OptionalBasicsView(
store: Store(
initialState: OptionalBasics.State(optionalCounter: Counter.State(count: 42)),
reducer: OptionalBasics()
)
initialState: OptionalBasics.State(optionalCounter: Counter.State(count: 42))
) {
OptionalBasics()
}
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,9 @@ struct SharedStateProfileView: View {
struct SharedState_Previews: PreviewProvider {
static var previews: some View {
SharedStateView(
store: Store(
initialState: SharedState.State(),
reducer: SharedState()
)
store: Store(initialState: SharedState.State()) {
SharedState()
}
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,9 @@ struct EffectsBasicsView_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
EffectsBasicsView(
store: Store(
initialState: EffectsBasics.State(),
reducer: EffectsBasics()
)
store: Store(initialState: EffectsBasics.State()) {
EffectsBasics()
}
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,9 @@ struct EffectsCancellation_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
EffectsCancellationView(
store: Store(
initialState: EffectsCancellation.State(),
reducer: EffectsCancellation()
)
store: Store(initialState: EffectsCancellation.State()) {
EffectsCancellation()
}
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,9 @@ struct LongLivingEffectsView: View {
struct EffectsLongLiving_Previews: PreviewProvider {
static var previews: some View {
let appView = LongLivingEffectsView(
store: Store(
initialState: LongLivingEffects.State(),
reducer: LongLivingEffects()
)
store: Store(initialState: LongLivingEffects.State()) {
LongLivingEffects()
}
)

return Group {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,9 @@ struct RefreshableView: View {
struct Refreshable_Previews: PreviewProvider {
static var previews: some View {
RefreshableView(
store: Store(
initialState: Refreshable.State(),
reducer: Refreshable()
)
store: Store(initialState: Refreshable.State()) {
Refreshable()
}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,9 @@ struct TimersView_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
TimersView(
store: Store(
initialState: Timers.State(),
reducer: Timers()
)
store: Store(initialState: Timers.State()) {
Timers()
}
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,9 @@ struct WebSocketView_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
WebSocketView(
store: Store(
initialState: WebSocket.State(receivedMessages: ["Hi"]),
reducer: WebSocket()
)
store: Store(initialState: WebSocket.State(receivedMessages: ["Hi"])) {
WebSocket()
}
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,10 @@ struct LoadThenNavigateListView_Previews: PreviewProvider {
LoadThenNavigateList.State.Row(count: 42, id: UUID()),
LoadThenNavigateList.State.Row(count: 100, id: UUID()),
]
),
reducer: LoadThenNavigateList()
)
)
) {
LoadThenNavigateList()
}
)
}
.navigationViewStyle(.stack)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,10 @@ struct NavigateAndLoadListView_Previews: PreviewProvider {
NavigateAndLoadList.State.Row(count: 42, id: UUID()),
NavigateAndLoadList.State.Row(count: 100, id: UUID()),
]
),
reducer: NavigateAndLoadList()
)
)
) {
NavigateAndLoadList()
}
)
}
.navigationViewStyle(.stack)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,9 @@ struct LoadThenNavigateView_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
LoadThenNavigateView(
store: Store(
initialState: LoadThenNavigate.State(),
reducer: LoadThenNavigate()
)
store: Store(initialState: LoadThenNavigate.State()) {
LoadThenNavigate()
}
)
}
.navigationViewStyle(.stack)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,9 @@ struct NavigateAndLoadView_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
NavigateAndLoadView(
store: Store(
initialState: NavigateAndLoad.State(),
reducer: NavigateAndLoad()
)
store: Store(initialState: NavigateAndLoad.State()) {
NavigateAndLoad()
}
)
}
.navigationViewStyle(.stack)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,9 @@ struct LoadThenPresentView_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
LoadThenPresentView(
store: Store(
initialState: LoadThenPresent.State(),
reducer: LoadThenPresent()
)
store: Store(initialState: LoadThenPresent.State()) {
LoadThenPresent()
}
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,9 @@ struct PresentAndLoadView_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
PresentAndLoadView(
store: Store(
initialState: PresentAndLoad.State(),
reducer: PresentAndLoad()
)
store: Store(initialState: PresentAndLoad.State()) {
PresentAndLoad()
}
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,9 @@ struct Lifecycle_Previews: PreviewProvider {
Group {
NavigationView {
LifecycleDemoView(
store: Store(
initialState: LifecycleDemo.State(),
reducer: LifecycleDemo()
)
store: Store(initialState: LifecycleDemo.State()) {
LifecycleDemo()
}
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,9 @@ struct NestedView_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
NestedView(
store: Store(
initialState: .mock,
reducer: Nested()
)
store: Store(initialState: .mock) {
Nested()
}
)
}
}
Expand Down
Loading