Skip to content

Commit d88c3f2

Browse files
committed
task: Fix samples to pass tests
1 parent 92722ad commit d88c3f2

22 files changed

+176
-211
lines changed

.swiftpm/xcode/xcshareddata/xcschemes/GoodReactor-Package.xcscheme

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@
3535
ReferencedContainer = "container:">
3636
</BuildableReference>
3737
</BuildActionEntry>
38+
<BuildActionEntry
39+
buildForTesting = "YES"
40+
buildForRunning = "YES"
41+
buildForProfiling = "YES"
42+
buildForArchiving = "YES"
43+
buildForAnalyzing = "YES">
44+
<BuildableReference
45+
BuildableIdentifier = "primary"
46+
BlueprintIdentifier = "LegacyReactor"
47+
BuildableName = "LegacyReactor"
48+
BlueprintName = "LegacyReactor"
49+
ReferencedContainer = "container:">
50+
</BuildableReference>
51+
</BuildActionEntry>
3852
</BuildActionEntries>
3953
</BuildAction>
4054
<TestAction

Package.swift

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ let package = Package(
1515
targets: ["GoodReactor"]
1616
),
1717
.library(
18-
name: "NewReactor",
19-
targets: ["NewReactor"]
18+
name: "LegacyReactor",
19+
targets: ["LegacyReactor"]
2020
)
2121
],
2222
dependencies: [
@@ -29,30 +29,25 @@ let package = Package(
2929
.target(
3030
name: "GoodReactor",
3131
dependencies: [
32-
.product(name: "CombineExt", package: "CombineExt")
32+
.product(name: "AsyncAlgorithms", package: "swift-async-algorithms"),
33+
.product(name: "Collections", package: "swift-collections"),
34+
.product(name: "GoodLogger", package: "GoodLogger")
3335
],
3436
path: "./Sources/GoodReactor",
3537
swiftSettings: [.swiftLanguageMode(.v6)]
3638
),
3739
.target(
38-
name: "NewReactor",
40+
name: "LegacyReactor",
3941
dependencies: [
40-
.product(name: "AsyncAlgorithms", package: "swift-async-algorithms"),
41-
.product(name: "Collections", package: "swift-collections"),
42-
.product(name: "GoodLogger", package: "GoodLogger")
42+
.product(name: "CombineExt", package: "CombineExt")
4343
],
44-
path: "./Sources/NewReactor",
44+
path: "./Sources/LegacyReactor",
4545
swiftSettings: [.swiftLanguageMode(.v6)]
4646
),
4747
.testTarget(
4848
name: "GoodReactorTests",
4949
dependencies: ["GoodReactor"],
5050
swiftSettings: [.swiftLanguageMode(.v6)]
51-
),
52-
.testTarget(
53-
name: "NewReactorTests",
54-
dependencies: ["NewReactor"],
55-
swiftSettings: [.swiftLanguageMode(.v6)]
5651
)
5752
]
5853
)
File renamed without changes.
Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// NewReactor.swift
2+
// Reactor.swift
33
// GoodReactor
44
//
55
// Created by Filip Šašala on 23/08/2024.
@@ -139,6 +139,17 @@ import SwiftUI
139139
func transform()
140140

141141
#if canImport(Combine)
142+
/// Creates subscriptions to external events, that supply events to this Reactor.
143+
///
144+
/// You override this function to merge your custom publisher chains with
145+
/// a provided event publisher (in parameter).
146+
/// ```swift
147+
/// func transform(event: AnyPublisher<Event.Kind, Never>) -> AnyPublisher<Event.Kind, Never> {
148+
/// return event
149+
/// .merge(with: myCustomPublisher.map { .mutation(.changeValue($0)) }
150+
/// .eraseToAnyPublisher()
151+
/// }
152+
/// ```
142153
func transform(event: AnyPublisher<Event.Kind, Never>) -> AnyPublisher<Event.Kind, Never>
143154
#endif
144155

@@ -203,7 +214,7 @@ public extension Reactor {
203214

204215
public extension Reactor {
205216

206-
typealias Event = NewReactor.Event<Action, Mutation, Destination>
217+
typealias Event = GoodReactor.Event<Action, Mutation, Destination>
207218

208219
static var logger: GoodLogger {
209220
MapTables.loggers.forceCastedValue(forKey: self, default: makeLogger())
@@ -330,11 +341,30 @@ public extension Reactor {
330341
}
331342
}
332343
}
333-
334-
/// <#Description#>
344+
345+
/// Create a new subscription to external event publisher for current reactor.
346+
///
347+
/// The subscription is stored and kept active until the reactor is deallocated
348+
/// or a `finish` event is received.
349+
///
350+
///
351+
///
352+
/// ## Usage
353+
/// ```swift
354+
/// func transform() {
355+
/// subscribe {
356+
/// externalValuePublisher
357+
/// } map: {
358+
/// .changeValue($0)
359+
/// }
360+
/// }
361+
/// ```
335362
/// - Parameters:
336-
/// - publisherProvider: <#publisherProvider description#>
337-
/// - mapper: <#mapper description#>
363+
/// - publisherProvider: Resolution of an external publisher of any type of value
364+
/// - mapper: Map function mapping received values to this reactor's Mutations.
365+
///
366+
/// - important: Call from the `transform` function. Remember to `start()`
367+
/// the reactor to properly initalize the subscriptions.
338368
func subscribe<Value>(
339369
to publisherProvider: @escaping @autoclosure () -> @Sendable () async -> Publisher<Value>,
340370
map mapper: @escaping @autoclosure () -> @Sendable (Value) async -> (Mutation)
@@ -468,16 +498,6 @@ public extension Reactor {
468498

469499
}
470500

471-
// MARK: - CustomStringConvertible
472-
473-
//public extension Reactor {
474-
//
475-
// nonisolated var description: String {
476-
// String(describing: Self.self)
477-
// }
478-
//
479-
//}
480-
481501
// MARK: - Migration
482502

483503
public extension Reactor {

0 commit comments

Comments
 (0)