mirror of
https://github.com/pointfreeco/swift-composable-architecture.git
synced 2025-12-24 12:14:25 +01:00
* wip
* fix
* wip
* wip
* move
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* Fix
* wip
* wip
* Renamed action to onTap in NavigationLinkStore (#2043)
Renamed the `action` parameter to mirror other inits and differentiate itself from `action fromDestinationAction`
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* Tie view identity to stack element identity
* Tie item identity to case
* wip
* wip
* cleanup
* fix
* fix
* Add warning to nav link
* wip
* wip
* Rename FullscreenCover.swift to FullScreenCover.swift (#2062)
* wip
* fix isDetailLink on non-iOS platforms
* Correct some comments in Effect.swift (#2081)
* add integration tests for showing alert/dialog from alert/dialog.
* copy StackElementIDGenerator dependency before running TestStore receive closure.
* Removed some unneeded delegate actions.
* wip
* clean up
* lots of clean up
* Converted voice memos back to identified array
* update deps
* update docs for DismissEffect
* wip
* Add Sendable conformance to PresentationState (#2086)
* wip
* swift-format
* wip
* wip
* docs
* wip
* wip
* Catch some typos in Articles (#2088)
* wip
* wip
* wip
* wip
* wip
* docs
* wip
* wip
* docs
* wip
* wip
* wip
* wip
* docs
* docs
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* Fix invalid states count for 3 optionals and typos (#2094)
* wip
* wip
* more dismisseffect docs
* fixed some references
* navigation doc corrections
* more nav docs
* fix cancellation tests in release mode
* wrap some tests in #if DEBUG since they are testing expected failures
* update UUIDs in tests to use shorter initializer
* fixed a todo
* wip
* fix merge errors
* wip
* fix
* wip
* wip
* fixing a bunch of todos
* get rid of rawvalue in StackElementID
* more todos
* NavLinkStore docs
* fix swift 5.6 stuff
* fix some standups tests
* fix
* clean up
* docs fix
* fixes
* wip
* 5.6 fix
* wip
* wip
* dont parallelize tests
* updated demo readmes
* wip
* Use ObservedObject instead of StateObject for alert/dialog modifiers.
* integration tests for bad dismissal behavior
* check for runtime warnings in every integration test
* wip
* wip
* fix
* wip
* wip
* wip
* wip
* wip
* Drop a bunch of Hashables.
* some nav bug fixes
* wip
* wip
* wip
* fix
* fix
* wip
* wip
* Simplify recording test.
* add concurrent async test
* fix
* wip
* Refact how detail dismisses itself.
* fix
* 5.6 fix
* wip
* wip
* Add TestStore.assert.
* Revert "Add TestStore.assert."
This reverts commit a892cccc66.
* add Ukrainian Readme.md (#2121)
* Add TestStore.assert. (#2123)
* Add TestStore.assert.
* wip
* Update Sources/ComposableArchitecture/TestStore.swift
Co-authored-by: Stephen Celis <stephen@stephencelis.com>
* Update Sources/ComposableArchitecture/Documentation.docc/Extensions/TestStore.md
Co-authored-by: Stephen Celis <stephen@stephencelis.com>
* fix tests
---------
Co-authored-by: Stephen Celis <stephen@stephencelis.com>
* Run swift-format
* push for store.finish and presentation
* move docs around
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* Add case subscripts
* wip
* wip
* 5.7-only
* wip
* wip
* wip
* wip
* revert store.finish task cancellation
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* add test for presentation scope
* wip
* wip
* wip
* wip
* wip
* cleanup
* updated presentation scope test
* sytnax update
* clean up
* fix test
* wip
* wip
* wip
* wip
* wip
---------
Co-authored-by: Brandon Williams <mbrandonw@hey.com>
Co-authored-by: Martin Václavík <mvaclavik96@icloud.com>
Co-authored-by: 유재호 <y73447jh@gmail.com>
Co-authored-by: Jackson Utsch <jutechs@gmail.com>
Co-authored-by: Dmytro <barabashdmyto@gmail.com>
Co-authored-by: Brandon Williams <135203+mbrandonw@users.noreply.github.com>
Co-authored-by: mbrandonw <mbrandonw@users.noreply.github.com>
145 lines
3.9 KiB
Swift
145 lines
3.9 KiB
Swift
/// A result builder for combining reducers into a single reducer by running each, one after the
|
|
/// other, and merging their effects.
|
|
///
|
|
/// It is most common to encounter a reducer builder context when conforming a type to
|
|
/// ``ReducerProtocol`` and implementing its ``ReducerProtocol/body-swift.property-97ymy`` property.
|
|
///
|
|
/// See ``CombineReducers`` for an entry point into a reducer builder context.
|
|
@resultBuilder
|
|
public enum ReducerBuilder<State, Action> {
|
|
@inlinable
|
|
public static func buildArray<R: ReducerProtocol>(_ reducers: [R]) -> _SequenceMany<R>
|
|
where R.State == State, R.Action == Action {
|
|
_SequenceMany(reducers: reducers)
|
|
}
|
|
|
|
@inlinable
|
|
public static func buildBlock() -> EmptyReducer<State, Action> {
|
|
EmptyReducer()
|
|
}
|
|
|
|
@inlinable
|
|
public static func buildBlock<R: ReducerProtocol>(_ reducer: R) -> R
|
|
where R.State == State, R.Action == Action {
|
|
reducer
|
|
}
|
|
|
|
@inlinable
|
|
public static func buildEither<R0: ReducerProtocol, R1: ReducerProtocol>(
|
|
first reducer: R0
|
|
) -> _Conditional<R0, R1>
|
|
where R0.State == State, R0.Action == Action {
|
|
.first(reducer)
|
|
}
|
|
|
|
@inlinable
|
|
public static func buildEither<R0: ReducerProtocol, R1: ReducerProtocol>(
|
|
second reducer: R1
|
|
) -> _Conditional<R0, R1>
|
|
where R0.State == State, R0.Action == Action {
|
|
.second(reducer)
|
|
}
|
|
|
|
@inlinable
|
|
public static func buildExpression<R: ReducerProtocol>(_ expression: R) -> R
|
|
where R.State == State, R.Action == Action {
|
|
expression
|
|
}
|
|
|
|
@inlinable
|
|
public static func buildFinalResult<R: ReducerProtocol>(_ reducer: R) -> R
|
|
where R.State == State, R.Action == Action {
|
|
reducer
|
|
}
|
|
|
|
@inlinable
|
|
public static func buildLimitedAvailability<R: ReducerProtocol>(
|
|
_ wrapped: R
|
|
) -> Reduce<State, Action>
|
|
where R.State == State, R.Action == Action {
|
|
Reduce(wrapped)
|
|
}
|
|
|
|
@inlinable
|
|
public static func buildOptional<R: ReducerProtocol>(_ wrapped: R?) -> R?
|
|
where R.State == State, R.Action == Action {
|
|
wrapped
|
|
}
|
|
|
|
@inlinable
|
|
public static func buildPartialBlock<R: ReducerProtocol>(
|
|
first: R
|
|
) -> R
|
|
where R.State == State, R.Action == Action {
|
|
first
|
|
}
|
|
|
|
@inlinable
|
|
public static func buildPartialBlock<R0: ReducerProtocol, R1: ReducerProtocol>(
|
|
accumulated: R0, next: R1
|
|
) -> _Sequence<R0, R1>
|
|
where R0.State == State, R0.Action == Action {
|
|
_Sequence(accumulated, next)
|
|
}
|
|
|
|
public enum _Conditional<First: ReducerProtocol, Second: ReducerProtocol>: ReducerProtocol
|
|
where
|
|
First.State == Second.State,
|
|
First.Action == Second.Action
|
|
{
|
|
case first(First)
|
|
case second(Second)
|
|
|
|
@inlinable
|
|
public func reduce(into state: inout First.State, action: First.Action) -> EffectTask<
|
|
First.Action
|
|
> {
|
|
switch self {
|
|
case let .first(first):
|
|
return first.reduce(into: &state, action: action)
|
|
|
|
case let .second(second):
|
|
return second.reduce(into: &state, action: action)
|
|
}
|
|
}
|
|
}
|
|
|
|
public struct _Sequence<R0: ReducerProtocol, R1: ReducerProtocol>: ReducerProtocol
|
|
where R0.State == R1.State, R0.Action == R1.Action {
|
|
@usableFromInline
|
|
let r0: R0
|
|
|
|
@usableFromInline
|
|
let r1: R1
|
|
|
|
@usableFromInline
|
|
init(_ r0: R0, _ r1: R1) {
|
|
self.r0 = r0
|
|
self.r1 = r1
|
|
}
|
|
|
|
@inlinable
|
|
public func reduce(into state: inout R0.State, action: R0.Action) -> EffectTask<R0.Action> {
|
|
self.r0.reduce(into: &state, action: action)
|
|
.merge(with: self.r1.reduce(into: &state, action: action))
|
|
}
|
|
}
|
|
|
|
public struct _SequenceMany<Element: ReducerProtocol>: ReducerProtocol {
|
|
@usableFromInline
|
|
let reducers: [Element]
|
|
|
|
@usableFromInline
|
|
init(reducers: [Element]) {
|
|
self.reducers = reducers
|
|
}
|
|
|
|
@inlinable
|
|
public func reduce(
|
|
into state: inout Element.State, action: Element.Action
|
|
) -> EffectTask<Element.Action> {
|
|
self.reducers.reduce(.none) { $0.merge(with: $1.reduce(into: &state, action: action)) }
|
|
}
|
|
}
|
|
}
|