Commit Graph

750 Commits

Author SHA1 Message Date
Stephen Celis
3ef0adcd79 Update CI to use macOS 13 (#2060)
* Update CI to use macOS 13

* wip

* wip

* wip

* wip

* wip

* wip
2023-04-26 09:10:09 -07:00
Stephen Celis
14c11ade59 Don't pass file and line to runtime warnings (#2059)
Runtime warnings are not test helpers that should propagate XCTest
failures to the original file/line, so we should always omit that
information. This leads to better test failures that show up alongside
the test, not buried in application code.
2023-04-25 11:40:02 -07:00
Brandon Williams
e12f200eef Clean up skipInFlightEffects and write test on beahvior. (#2057) 2023-04-25 09:48:49 -07:00
유재호
ce187a4d08 Update remaining 'bindable state' to 'binding state' (#2054) 2023-04-25 09:38:05 -07:00
YOUNG MO SONG
30869bb594 update line-wrapping convention (#2056) 2023-04-25 08:53:50 -07:00
Matteo Girardi
93c0aa3fc5 Fix withTaskCancellation documentation (#2049)
Remove `.self` from enum type
2023-04-18 06:50:56 -04:00
Stephen Celis
fbfb245b7d Revert #2033 (#2044)
* Revert #2033

See https://github.com/pointfreeco/swift-dependencies/pull/83 for more
info.

* wip
2023-04-14 15:25:55 -07:00
Stephen Celis
9a97dd4cd6 Export withMainSerialExecutor (#2033)
* wip

* Move `_withMainSerialExecutor` to swift-dependencies

* bump
2023-04-13 14:36:32 -07:00
Stephen Celis
4192a843ee Pass state to SwitchStore.init view builder (#2029)
* Pass state to `SwitchStore.init` view builder

Rather than rely on many, many overloads of `SwitchStore.init` to
strictly accept only `CaseLet`s and an optional, final `Default` view,
let's introduce a single initializer without constraints that is passed
the current state whenever the case changes. This state can be switched
on and route to the appropriate view via `CaseLet`.

The pros:

  * We get exhaustive switching at compile time.

  * We get more flexibility in the view layer. Previously, any
    customization needed to be pushed into the `CaseLet` builder, but
    now `CaseLet` can freely apply view modifiers.

  * We can deprecate and eventually remove the many, many initializer
    overloads, and hopefully slim down binary size in the process, and
    improve view builder compile times when dealing with `SwitchStore`.
    We can also deprecate and eventually remove `Default`.

The cons:

  * It's slightly more verbose and repetitive. You have a `SwitchStore`
    and then a `switch` inside it with many `case`s with `CaseLet`s
    inside them, and the `case .screen:` is followed by
    `CaseLet(/State.screen, ...)`.

  * One is free to extract the state's associated value(s) and use it to
    render a view, but this view will be inert and will not re-render if
    the value it depends on changes in the store. This can lead to some
    surprises, but we can document against the pattern, and maybe in the
    future we can use something like macros to prevent this from being
    possible.

  * You can still get things wrong if you're not careful: there's
    nothing enforcing that the `case` you switch on is the same case you
    send to `CaseLet`, so `case .screenA: CaseLet(/State.screenB, ...)`
    is possible. While unlikely, it's still a copy-paste error in
    waiting.

* wip

* wip

* wip

* Bump

* fix test

* clean up

* clean up

* clean up

* wip

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
2023-04-10 11:37:02 -07:00
Ryu
23501d36a7 Fix Document in BindingAction (#2019) 2023-04-03 08:25:29 -07:00
Michael Housh
ba06026d7d Fixed missing action tag in for each store documentation (#1998) 2023-03-27 13:44:44 -07:00
Stephen Celis
bcb134b7ac Don't disable _printChanges() in tests (#1995)
* Don't disable `_printChanges()` in tests

It can be handy to have this logging during a test, so let's not go out of our way to suppress it.

* Update DebugReducer.swift
2023-03-23 10:13:34 -07:00
Stephen Celis
619cb405a2 Escape dependencies to EffectTask.publisher (#1988) 2023-03-21 12:00:20 -07:00
mbrandonw
1a5876c4cf Run swift-format 2023-03-15 20:03:36 +00:00
Brandon Williams
da6e07c1ec Cancellation cleanup (#1977)
* Clean up effect cancellation.

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* cancel id test

* nb

* benchmark

* wip

* wip

* wip

* wip

* wip

* clean up

* wip
2023-03-15 12:50:20 -07:00
Brandon Williams
d73a3494bf Better type names in WithViewStore.debug. (#1973) 2023-03-15 08:25:47 -07:00
Matteo Girardi
016725483e Fix grammar in doc (#1963)
* Fix documentation

- improve grammar in doc

* Revert to previous sentence
2023-03-07 13:51:11 -08:00
stephencelis
2c0caf6fc3 Run swift-format 2023-03-06 22:27:35 +00:00
Stephen Celis
3029263c10 Add 'Effect.publisher' for bridging effects from Combine (#1958)
We are looking to deprecate TCA's dependence on Combine, _e.g._ the
direct conformance of `Effect` to `Publisher`, as well as many
Combine-centric APIs, but that doesn't mean we want to eliminate support
for using Combine with TCA. Our current advice given by our soft
deprecations is to iterate over `publisher.values`, but this is
unavailable in iOS 13 and 14, so let's introduce a dedicated bridging
mechanism, instead.
2023-03-06 13:46:20 -08:00
Stephen Celis
bb384617d9 Clean up uncategorized DocC (#1956) 2023-03-06 09:54:42 -08:00
Sven A. Schmidt
ece109fa32 Fix types, .forEach() call (#1957) 2023-03-06 07:32:34 -08:00
Thomas Grapperon
083ecd5af7 Rollback Effect<Action>.Send to a top level EffectSend<Action> (#1930)
* Rollback to a top level `Send`

* Rename `EffectSend` as `Send`

* Add a `Sendable` typealias to `ReducerProtocol`

* Revert "Add a `Sendable` typealias to `ReducerProtocol`"

This reverts commit d808d3c916.

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
2023-03-05 17:24:37 -08:00
Brandon Williams
0a6f2b2b2d Fix TestStore.init with prepareDependencies. (#1955)
* Fix TestStore.init with prepareDependencies.

* Update Tests/ComposableArchitectureTests/TestStoreTests.swift

Co-authored-by: Oron Ben Zvi <oronbz@gmail.com>

* Update Tests/ComposableArchitectureTests/TestStoreTests.swift

Co-authored-by: Oron Ben Zvi <oronbz@gmail.com>

---------

Co-authored-by: Oron Ben Zvi <oronbz@gmail.com>
2023-03-05 15:54:36 -08:00
Brandon Williams
a0beb199bc Do not propagate dependencies to effect actions. (#1954)
* wip

* wip

* wip

* wip

* wip

* wip

* wip
2023-03-05 15:53:44 -08:00
Brandon Williams
f081ed4c31 Add @warn_unqualified_access to reducer operators. (#1950) 2023-02-28 13:50:09 -08:00
Brandon Williams
44b4d63695 Fix for swift-format. 2023-02-27 08:53:34 -08:00
Stephen Celis
685e8fcfc0 DocC fixes (#1942)
We have a number of outdated DocC references. This PR should hopefully
take care of them!
2023-02-27 08:29:19 -08:00
mbrandonw
58d00639f6 Run swift-format 2023-02-26 04:44:19 +00:00
Kristoffer Johansson
6f9ee72229 Adds missing documentation for the Store initializer (#1940)
* Add missing `Store` initializer documentation

* Update Sources/ComposableArchitecture/Store.swift

* Update and rename Store.swift to Store.swift

---------

Co-authored-by: Brandon Williams <135203+mbrandonw@users.noreply.github.com>
2023-02-25 20:12:59 -08:00
Brandon Williams
df307eb968 Make the new XCTModify play nicely with non-exhaustive testing. (#1939)
* Make the new XCTModify play nicely with non-exhaustive testing.

* wip

* Update Tests/ComposableArchitectureTests/TestStoreNonExhaustiveTests.swift

Co-authored-by: Stephen Celis <stephen@stephencelis.com>

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
2023-02-24 12:10:21 -08:00
Kabir Oberai
cd22f6a1b3 Warn if send is called after .run completes (#1900)
* Warn if send called after effect completes

When an Effect.run is converted into a publisher, we already end up discarding `send`s sent after returning. Similarly, `*Task.finish()` will fail to track send()s after other in-flight effects complete. This is effectively UB so let's warn about it.

* Fix tests

* we don't need to print TestAction yet

* Tweak messaging and tests.

* fix tests

* wip

* fix tests part 2

* fix tests part 3

* Wrap testCancellation test in _withMainSerialExecutor

* Update Publisher.swift

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
Co-authored-by: Stephen Celis <stephen@stephencelis.com>
Co-authored-by: Stephen Celis <stephen.celis@gmail.com>
2023-02-17 11:28:31 -08:00
Stephen Celis
0087051b99 Fix some Xcode 14.3 warnings (#1920) 2023-02-17 10:26:33 -08:00
Brandon Williams
df9284174a Force WithViewStore to be a view. (#1910) 2023-02-17 09:21:44 -08:00
Thomas Grapperon
91e2bea845 Nest Send<Action> as Effect<Action>.Send (#1911) 2023-02-17 09:20:20 -08:00
Thomas Grapperon
56a1e4b8e0 Re-enable _printChanges() for previews (#1917)
* Re-enable `_printChanges()` for previews

* Remove the covering test
2023-02-17 08:37:15 -08:00
Stephen Celis
1b998c43b3 Remove Identified type from library (#1907)
* Remove `Identified` type from library

It's now included in swift-identified-collections.

* wip
2023-02-14 09:16:05 -08:00
Stephen Celis
5d490c71c3 Make reducer builder closure parameters explicit (#1897)
- Scope(...🧒)
  - forEach(...:element:)

The one exception is `CombineReducers`, which already includes the
`Reducers` in its name.
2023-02-09 09:58:23 -08:00
Eimantas
c1a141146d Fix typo in Effect deprecation notice (#1896) 2023-02-09 07:03:49 -08:00
Matt Girardi
74c7a6fdf3 Fix documentation (#1893)
Fix a tiny typo
2023-02-07 11:39:52 -08:00
mbrandonw
b32b1ac650 Run swift-format 2023-02-05 21:47:31 +00:00
Brandon Williams
3b1fabe47a Unavailable TestStore.send/receive when state/action is not Equatable (#1890)
* Add unavailable TestStore.send/receive.

* wip

* wip
2023-02-05 13:36:32 -08:00
Stephen Celis
5e4caa89ee Improve expected action test store failure message (#1883)
* Improve expected action test store failure message

We currently interpolate the action directly, which prints in a pretty
crude format that becomes almost incomprehensible for deeply nested
actions (common in "integration" tests). So let's leverage Custom Dump
instead!

* Bump
2023-01-30 17:56:38 -08:00
Stephen Celis
b690a617d1 Make Store.filter internal (#1882)
* Make Store.filter internal

We're seeing that `@_spi` can still come up in autocomplete. Now Xcode
surfaces internal stuff too occasionally, but maybe this will suppress
it a bit.

* wip

* fix
2023-01-30 12:31:23 -08:00
Stephen Celis
c330496164 Workaround for BindingAction existential layout crash (#1881)
* Add test case for binding action crash

* Workaround layout issue

* flakey test

* wip
2023-01-30 10:57:04 -08:00
Stephen Celis
98af2adcb5 IfLetStore: ignore view store binding writes to nil state (#1879)
* `IfLetStore`: ignore view store binding writes to `nil` state

* swift-format

* wip

* add test for filter

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
2023-01-27 13:59:43 -08:00
Stephen Celis
1a168e2397 Add note to reducer protocol dependency section (#1873)
* Add note to reducer protocol dependency section

The discussion #1870 noted that our migration guide could include more
of a breadcrumb that migrating to the Dependencies library isn't a
simple matter of changing every environment property to a `@Dependency`
property.

* wip

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
2023-01-26 09:22:30 -08:00
Stephen Celis
63972fa9ea Update SwiftUI Navigation to support new alert mappings (#1865)
* wip

* wip

* wip

* Bump

* Update AlertStateUIKit.swift
2023-01-25 11:36:18 -08:00
Stephen Celis
761ab290f4 Improve reducer builder inference and prepare for Swift 5.8 (#1863)
* Update builders for changes coming in Swift 5.8

* wip

* wip
2023-01-25 10:10:32 -08:00
Stephen Celis
e294b24edb Add Effect.send (#1859)
* Add `Effect.send`

With the `Effect<Action, Failure>` -> `Effect<Action>` migration,
`Effect.init(value:)` and `Effect.init(error:)` no longer make sense. We
will be retiring the latter some time in the future, so let's also get a
head start and rename the former to `Effect.send`.

For now it will call `Effect.init(value:)` under the hood, but in the
future we will want a non-Combine-driven way of running synchronous
effects.

* format fix

* wip

* fix

* wip

* wip
2023-01-23 16:41:01 -08:00
Brandon Williams
6f33e07a7a Use @StateObject for iOS 15+ alert modifier. (#1860) 2023-01-23 16:04:28 -08:00