mirror of
https://github.com/pointfreeco/swift-composable-architecture.git
synced 2025-12-20 09:11:33 +01:00
* Add an `EffectOf<Action>` typealias for `Effect<Action, Never>` * Fix doc * Rename `EffectOf` to `EffectTask` * Rename `Effect` to `EffectPublisher` * Soft-deprecate `Effect` * Link to `EffectTask` * Use `EffectPublisher` in Combine contexts * Reword soft-deprecation message * Remove `renamed:` fix-it for `Effect` deprecation * Update Sources/ComposableArchitecture/Documentation.docc/Extensions/ReducerProtocol.md Co-authored-by: Stephen Celis <stephen.celis@gmail.com> * Update Sources/ComposableArchitecture/Documentation.docc/ComposableArchitecture.md * Update Sources/ComposableArchitecture/Effect.swift * Fix DocC identifiers Co-authored-by: Stephen Celis <stephen.celis@gmail.com>
31 lines
730 B
Swift
31 lines
730 B
Swift
import Benchmark
|
|
import ComposableArchitecture
|
|
|
|
private struct Counter: ReducerProtocol {
|
|
typealias State = Int
|
|
typealias Action = Bool
|
|
func reduce(into state: inout Int, action: Bool) -> EffectTask<Bool> {
|
|
if action {
|
|
state += 1
|
|
return .none
|
|
} else {
|
|
state -= 1
|
|
return .none
|
|
}
|
|
}
|
|
}
|
|
|
|
let storeScopeSuite = BenchmarkSuite(name: "Store scoping") { suite in
|
|
var store = Store(initialState: 0, reducer: Counter())
|
|
var viewStores: [ViewStore<Int, Bool>] = [ViewStore(store)]
|
|
for _ in 1...4 {
|
|
store = store.scope(state: { $0 })
|
|
viewStores.append(ViewStore(store))
|
|
}
|
|
let lastViewStore = viewStores.last!
|
|
|
|
suite.benchmark("Nested store") {
|
|
lastViewStore.send(true)
|
|
}
|
|
}
|