Skip to content

Commit 68287a5

Browse files
authored
Merge pull request #15 from trading-point/michael/sync-with-upstream
Sync with latest upstream changes
2 parents 3184ca3 + 52b76e3 commit 68287a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1295
-129
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,10 @@ jobs:
1616
xcode:
1717
- 11.4
1818
- 11.5
19+
- 11.6
1920
steps:
2021
- uses: actions/checkout@v2
2122
- name: Select Xcode ${{ matrix.xcode }}
2223
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
2324
- name: Run tests
24-
run: make test-swift
25-
26-
examples:
27-
runs-on: macOS-latest
28-
strategy:
29-
matrix:
30-
xcode:
31-
- 11.4
32-
- 11.5
33-
steps:
34-
- uses: actions/checkout@v2
35-
- name: Select Xcode ${{ matrix.xcode }}
36-
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
37-
- name: Run tests
38-
run: make test-workspace
25+
run: make test

.github/workflows/documentation.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Documentation
2+
on:
3+
release:
4+
types:
5+
- published
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Generate Documentation
15+
uses: SwiftDocOrg/swift-doc@master
16+
with:
17+
base-url: /reactiveswift-composable-architecture/
18+
format: html
19+
inputs: Sources/ComposableArchitecture
20+
module-name: ComposableArchitecture
21+
output: Documentation
22+
- name: Deploy to GitHub Pages
23+
uses: JamesIves/github-pages-deploy-action@releases/v3
24+
with:
25+
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
26+
BRANCH: gh-pages
27+
FOLDER: Documentation

Examples/CaseStudies/CaseStudies.xcodeproj/project.pbxproj

Lines changed: 266 additions & 3 deletions
Large diffs are not rendered by default.

Examples/CaseStudies/SwiftUICaseStudies/00-Core.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ struct RootState {
1313
var effectsCancellation = EffectsCancellationState()
1414
var effectsTimers = TimersState()
1515
var episodes = EpisodesState(episodes: .mocks)
16+
var lifecycle = LifecycleDemoState()
1617
var loadThenNavigate = LoadThenNavigateState()
1718
var loadThenNavigateList = LoadThenNavigateListState()
1819
var loadThenPresent = LoadThenPresentState()
@@ -40,6 +41,7 @@ enum RootAction {
4041
case effectsBasics(EffectsBasicsAction)
4142
case effectsCancellation(EffectsCancellationAction)
4243
case episodes(EpisodesAction)
44+
case lifecycle(LifecycleDemoAction)
4345
case loadThenNavigate(LoadThenNavigateAction)
4446
case loadThenNavigateList(LoadThenNavigateListAction)
4547
case loadThenPresent(LoadThenPresentAction)
@@ -149,6 +151,12 @@ let rootReducer = Reducer<RootState, RootAction, RootEnvironment>.combine(
149151
action: /RootAction.episodes,
150152
environment: { .init(favorite: $0.favorite, mainQueue: $0.mainQueue) }
151153
),
154+
lifecycleDemoReducer
155+
.pullback(
156+
state: \.lifecycle,
157+
action: /RootAction.lifecycle,
158+
environment: { .init(mainQueue: $0.mainQueue )}
159+
),
152160
loadThenNavigateReducer
153161
.pullback(
154162
state: \.loadThenNavigate,

Examples/CaseStudies/SwiftUICaseStudies/00-RootView.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,16 @@ struct RootView: View {
226226
)
227227
)
228228

229+
NavigationLink(
230+
"Lifecycle",
231+
destination: LifecycleDemoView(
232+
store: self.store.scope(
233+
state: { $0.lifecycle },
234+
action: RootAction.lifecycle
235+
)
236+
)
237+
)
238+
229239
NavigationLink(
230240
"Strict reducers",
231241
destination: DieRollView(

Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-Animations.swift

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,24 @@ private let readMe = """
1717
toggle at the bottom of the screen.
1818
"""
1919

20+
extension Effect where Error == Never {
21+
public static func keyFrames(
22+
values: [(output: Value, duration: TimeInterval)],
23+
scheduler: DateScheduler
24+
) -> Effect {
25+
.concatenate(
26+
values
27+
.enumerated()
28+
.map { index, animationState in
29+
index == 0
30+
? Effect(value: animationState.output)
31+
: Effect(value: animationState.output)
32+
.delay(values[index - 1].duration, on: scheduler)
33+
}
34+
)
35+
}
36+
}
37+
2038
struct AnimationsState: Equatable {
2139
var circleCenter = CGPoint.zero
2240
var circleColor = Color.white
@@ -43,15 +61,10 @@ let animationsReducer = Reducer<AnimationsState, AnimationsAction, AnimationsEnv
4361
return .none
4462

4563
case .rainbowButtonTapped:
46-
return .concatenate(
47-
[Color.red, .blue, .green, .orange, .pink, .purple, .yellow, .white]
48-
.enumerated()
49-
.map { index, color in
50-
index == 0
51-
? Effect(value: .setColor(color))
52-
: Effect(value: .setColor(color))
53-
.delay(1, on: environment.mainQueue)
54-
}
64+
return .keyFrames(
65+
values: [Color.red, .blue, .green, .orange, .pink, .purple, .yellow, .white]
66+
.map { (output: .setColor($0), duration: 1) },
67+
scheduler: environment.mainQueue
5568
)
5669

5770
case let .setColor(color):

Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-OptionalState.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ enum OptionalBasicsAction: Equatable {
2323

2424
struct OptionalBasicsEnvironment {}
2525

26-
let optionalBasicsReducer = counterReducer
27-
.optional
26+
let optionalBasicsReducer =
27+
counterReducer
28+
.optional()
2829
.pullback(
2930
state: \.optionalCounter,
3031
action: /OptionalBasicsAction.optionalCounter,

Examples/CaseStudies/SwiftUICaseStudies/03-Navigation-Lists-LoadThenNavigate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ let loadThenNavigateListReducer =
4242
action: .self,
4343
environment: { $0 }
4444
)
45-
.optional
45+
.optional()
4646
.pullback(
4747
state: \LoadThenNavigateListState.selection,
4848
action: /LoadThenNavigateListAction.counter,

Examples/CaseStudies/SwiftUICaseStudies/03-Navigation-Lists-NavigateAndLoad.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ struct NavigateAndLoadListEnvironment {
3333
var mainQueue: DateScheduler
3434
}
3535

36-
let navigateAndLoadListReducer = counterReducer
37-
.optional
36+
let navigateAndLoadListReducer =
37+
counterReducer
38+
.optional()
3839
.pullback(state: \Identified.value, action: .self, environment: { $0 })
39-
.optional
40+
.optional()
4041
.pullback(
4142
state: \NavigateAndLoadListState.selection,
4243
action: /NavigateAndLoadListAction.counter,

Examples/CaseStudies/SwiftUICaseStudies/03-Navigation-LoadThenNavigate.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ struct LoadThenNavigateEnvironment {
2727
var mainQueue: DateScheduler
2828
}
2929

30-
let loadThenNavigateReducer = counterReducer
31-
.optional
30+
let loadThenNavigateReducer =
31+
counterReducer
32+
.optional()
3233
.pullback(
3334
state: \.optionalCounter,
3435
action: /LoadThenNavigateAction.optionalCounter,

0 commit comments

Comments
 (0)