Commit Graph

203 Commits

Author SHA1 Message Date
Stephen Celis
57e804f1cc Macro bonanza (#2553)
* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Silence test warnings

* wip

* wip

* wip

* update a bunch of docs

* wip

* wip

* fix

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Kill integration tests for now

* wip

* wip

* wip

* wip

* updating docs for @Reducer macro

* replaced more Reducer protocols with @Reducer

* Fixed some broken docc references

* wip

* Some @Reducer docs

* more docs

* convert some old styles to new style

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* bump

* update tutorials to use body

* update tutorials to use DML on destination state enum

* Add diagnostic

* wip

* updated a few more tests

* wip

* wip

* Add another gotcha

* wip

* wip

* wip

* fixes

* wip

* wip

* wip

* wip

* wip

* fix

* wip

* remove for now

* wip

* wip

* updated some docs

* migration guides

* more migration guide

* fix ci

* fix

* soft deprecate all apis using AnyCasePath

* wip

* Fix

* fix tests

* swift-format 509 compatibility

* wip

* wip

* Update Sources/ComposableArchitecture/Macros.swift

Co-authored-by: Mateusz Bąk <bakmatthew@icloud.com>

* wip

* wip

* update optional state case study

* remove initializer

* Don't use @State for BasicsView integration demo

* fix tests

* remove reduce diagnostics for now

* diagnose error not warning

* Update Sources/ComposableArchitecture/Macros.swift

Co-authored-by: Jesse Tipton <jesse@jessetipton.com>

* wip

* move integration tests to cron

* Revert "move integration tests to cron"

This reverts commit f9bdf2f04b.

* disable flakey tests on CI

* wip

* wip

* Revert "Revert "move integration tests to cron""

This reverts commit 66aafa7327.

* fix

* wip

* fix

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
Co-authored-by: Mateusz Bąk <bakmatthew@icloud.com>
Co-authored-by: Brandon Williams <135203+mbrandonw@users.noreply.github.com>
Co-authored-by: Jesse Tipton <jesse@jessetipton.com>
2023-11-13 12:57:35 -08:00
Brandon Williams
464d95e368 Add previews to integration test cases (#2551)
* Add previews to all integration tests.

* wip;

* wip

* wip

* debug

* xcode 15

* split out examples

* wip

* wip

* move around tests so they don't go off screen

* wip

* wip

* ops

* wip

* wip

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
2023-11-09 14:10:23 -08:00
Stephen Celis
87aeaf6f73 Use Text.init(verbatim:) to avoid localization warnings (#2541)
Fixes #2502.
2023-11-02 12:25:37 -07:00
Stephen Celis
5ba7943402 Internal: rename Store.{state,stateSubject} (#2538)
* Internal: rename `Store.{state,stateSubject}`

Both an internal readability win and will make it easier to provide a
public `state` property in the future.

* wip
2023-10-31 14:45:57 -07:00
linebyline
c08d59e94b fix WithViewStore extension document (#2511)
- remove unused paramter(isDuplicate)

Co-authored-by: 강성규/연구/인포테인먼트소프트웨어개발팀 <seongkue.kang@hyundai.com>
2023-10-09 20:08:13 -04:00
Stephen Celis
c0d8fbabfc Clean up and modernize docs/examples (#2480) 2023-09-28 06:58:51 -07:00
stephencelis
c56fad17b4 Run swift-format 2023-08-18 20:59:48 +00:00
Jared Henderson
98bdf8a3c4 Prevent crash on Catalina from missing symbol (#2385) 2023-08-18 13:55:43 -07:00
stephencelis
356be6a9c2 Run swift-format 2023-08-18 17:35:12 +00:00
Stephen Celis
93fa026cbc Re-introduce legacy alert and action sheet APIs (#2379)
* Re-introduce legacy alert and action sheet APIs

With 1.0 we removed `View.alert(_ store:dismiss:)`, which was a
problematic API. It used different SwiftUI alert APIs depending on OS
version, which led to different runtime behavior for apps using it
depending on the OS and an unfixable bug:

https://github.com/pointfreeco/swift-composable-architecture/issues/1981

This was reason enough to remove the API, but it was also an API that
predated the Composable Architecture's navigation tools. This meant it
awkwardly took an explicit `dismiss:` action, and it was up to the
developer to remember to use this action to manually clear out state.
The Composable Architecture's navigation tools handle dismissal
automatically once integrated, but also only support iOS 15 alerts at
the moment.

This PR addresses the above: it introduces view modifiers for the old
iOS 13 style of alert (and `actionSheet`) providing some presentation
domain, and it will automatically dismiss these modals accordingly:

  - It adds `View.legacyAlert(store:)`. While we don't love
    `legacyAlert`, we haven't come up with a better option. We need a
    statically unique view modifier, and `alert(store:)` is already in
    use for iOS 15. We're open to suggestions here, though!

  - It adds `View.actionSheet(store:)`.

* wip
2023-08-18 10:34:27 -07:00
Stephen Celis
195284b94b The Composable Architecture 1.0 (#2318)
* 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

* wip

* fix

* wip

* 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

* 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

* wip

* move docs around

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Add case subscripts

* wip

* wip

* wip

* 5.7-only

* wip

* wip

* wip

* wip

* fix

* 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

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Rename ReducerProtocol.swift to Reducer.swift (#2206)

* Hard-deprecate old SwitchStore initializers/overloads

* wip

* wip

* Resolve CaseStudies crash (#2258)

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Bump timeout for CI

* wip

* Remove old deprecations

* Simplify test store

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* images for tutorials

* wip

* wip

* Remove deprecated alert APIs

* Bump dependencies

* wip

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
Co-authored-by: 유재호 <y73447jh@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>
2023-07-30 14:58:40 -07:00
stephencelis
4cf2104cf1 Run swift-format 2023-07-30 18:05:28 +00:00
Stephen Celis
4406349a57 Deprecate old alert APIs in favor of new presentation APIs (#2335)
* Deprecate old alert APIs in favor of new presentation APIs

* wip

* wip

* wip
2023-07-30 11:01:38 -07:00
Stephen Celis
37b8a41e09 Allow chaining into BindingViewState (#2334)
Currently, `BindingViewStore`s can only directly derive
`BindingViewState` for a view state struct, and then the view store can
derive a binding and use dynamic member lookup to pluck out a field for
a view. This means potentially exposing view state to far more state
than necessary.

To prevent this we can add dynamic member lookup to the binding view
state itself, which allows a view state struct to chip away any state it
doesn't care about.
2023-07-30 10:53:46 -07:00
Brandon Williams
2c93195c23 Prerelease 1.0 (#1929)
* 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

* fix some warnings

* docs

* wip

* wip

* Catch some typos in Articles (#2088)

* wip

* wip

* wip

* 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

* wip

* fix

* wip

* 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

* 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

* wip

* move docs around

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Add case subscripts

* wip

* wip

* wip

* 5.7-only

* wip

* wip

* wip

* wip

* fix

* 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

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Rename ReducerProtocol.swift to Reducer.swift (#2206)

* Hard-deprecate old SwitchStore initializers/overloads

* wip

* wip

* Resolve CaseStudies crash (#2258)

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Bump timeout for CI

* wip

* wip

---------

Co-authored-by: Jackson Utsch <jutechs@gmail.com>
Co-authored-by: Stephen Celis <stephen@stephencelis.com>
Co-authored-by: 유재호 <y73447jh@gmail.com>
Co-authored-by: Dmytro <barabashdmyto@gmail.com>
Co-authored-by: mbrandonw <mbrandonw@users.noreply.github.com>
2023-07-27 17:35:07 -07:00
HanjunYu
bad761c919 Add Store.send(_ action:) return StoreTask (#2323)
Co-authored-by: hanjun-yu <hanjun.yu@snowcorp.com>
2023-07-26 09:23:39 -07:00
Stephen Celis
cc8f6611e9 Abbreviate nested binding action values (#2315)
* Abbreviate nested binding action values

Now that binding action key paths cannot use dynamic member lookup,
dumps are a little more unwieldy to read when nested state is involved.
Generally one can look at the state diff to figure out what changed, so
let's abbreviate the action's state when we can.

* wip
2023-07-21 08:47:30 -07:00
Stephen Celis
a1e454c1e6 Depend on ConcurrencyExtras (#2301)
* wip

* wip

* wip

Fixes #1902.

* wip

* wip

* wip

* wip

* fix

* added test for subscribe/receive

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
2023-07-17 15:54:15 -07:00
Timur Guliamov
945ab055a8 Fixed tree-based navigation: dismiss action is not sent when navigating back (#2210)
* fixed dismiss action sending when navigating back

* Revert "fixed dismiss action sending when navigating back"

This reverts commit 52f7340406.

* added integration ui test

* fixed id for presentation with `isPresented` parameter

* fixed integration tests
2023-07-17 14:36:13 -07:00
Stephen Celis
faadf6a780 Add named closure arguments (#2295)
* Add named closure arguments

Better for documentation and auto-fill.

* wip
2023-07-16 15:27:02 -07:00
Ben Lings
c113ba4f22 Fix for infinite loop when combining Stack and Tree navigation (#2289)
* Fix for https://github.com/pointfreeco/swift-composable-architecture/issues/2288

* Add navigation destination to NavigationStackTestCase

* Add UI test case

* clean up

---------

Co-authored-by: Ben Lings <ben.lings@bp.com>
Co-authored-by: Brandon Williams <mbrandonw@hey.com>
2023-07-16 15:24:03 -07:00
Stephen Celis
c28311e351 Fix macOS dismissal (#2284)
Fixes #2182.

The `id` used for comparison appears to sometimes be `nil`, for example
on macOS when drilling out of a `navigationDestination`. This PR adds a
little nuance to the dismissal logic of `presentationModifier`:

  * It explicitly checks that something is presented
  * It always sends `dismiss` if the cached `id` was `nil`

We should maybe have some integration tests for macOS for this...
2023-07-14 10:31:18 -07:00
Stephen Celis
d69b5db82c Fix view state binding equatability (#2255)
* Fix view state binding equatability

* wip

* wip

* wip

* wip

* wip
2023-07-12 16:25:55 -07:00
Stephen Celis
663a45f39d Fix WithViewStore initializer ambiguity (#2278)
* Test to show when ambiguous init of ViewStore happens

* Fix #2275

* wip

---------

Co-authored-by: Johan Kool <johankool@users.noreply.github.com>
2023-07-12 14:23:39 -07:00
Jesse Tipton
d2d3c149cc Add BindingViewStore initializers for ViewStore (#2274) 2023-07-12 14:09:40 -07:00
Jesse Tipton
745bc10361 Fix commas that should be periods in docs (#2267) 2023-07-07 22:36:50 -07:00
bharath2020
d74930b494 Fixed BindingAction.set(keyPath:value:) causes equality test on value to fail (#2248)
* Fixed BindingAction.set(keyPath:value:) causes equality test on value to fail

* clean up

---------

Co-authored-by: Bharath Booshan <bbooshan@atlassian.com>
Co-authored-by: Brandon Williams <mbrandonw@hey.com>
2023-06-30 11:20:15 -04:00
Stephen Celis
f2de7e7f66 Weaken BindingViewStore's dynamic member lookup (#2243)
Right now it requires a writably, equatable property, but that prevents
accessing `let` constants on state.
2023-06-29 08:30:26 -07:00
Stephen Celis
89f80fe240 Bump swiftui-navigation (#2239)
* Bump swiftui-navigation

* fix deprecation warning

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
2023-06-28 12:30:52 -07:00
stephencelis
93c878441b Run swift-format 2023-06-28 18:57:06 +00:00
Stephen Celis
43e28a57f3 Update docs for next release (#2238)
* Update docs for next release

* wip

* fix deprecations

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
2023-06-28 11:34:01 -07:00
stephencelis
461ee90b74 Run swift-format 2023-06-28 16:36:43 +00:00
Stephen Celis
daf41b3370 Add public Store.send and Store.withValue (#2222) 2023-06-28 09:32:32 -07:00
Stephen Celis
95d2bc701b Better Bindings Revisited (#2215)
* Simpler bindable view state

* wip

* wip

* wip

* wip

* wip

* wip

* simplify

* wip

* wip

* wip

* wip

* wip

* wip

* wip
2023-06-28 09:31:12 -07:00
Daniel Peter
bd23264956 Avoid force-unwrapping cached value in ForEachStore (#1036)
* Avoid force-unwrapping cached value in ForEachStore

* ForEach closure based caching approach

* Uses unnamed closure parameters

* Define custom remove duplicates to only reevaluate when IDs change

* fix

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
2023-06-21 17:36:00 -07:00
Alex Hunsley
42b01f284e Fix some swiftdoc and small tidy (#2204)
* Remove double word and a little grammar gardening

* Fix some swiftdoc parameters

* Tidy params to '_' in DataManager
2023-06-16 07:49:38 -07:00
Daiki Matsudate
b4a3420ded Fix docs (#2174) 2023-06-04 11:45:44 -07:00
mbrandonw
8b98ba40a2 Run swift-format 2023-05-30 16:25:21 +00:00
Stephen Celis
c432a76b5b Navigation (#1945)
* 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>
2023-05-30 12:22:00 -04:00
Brandon Williams
3688b3d485 Make Send sendable (#2112)
* Make Send wrap a sendable closure.

* Move Send under the effects docs.

* Fixed a bunch of doc references.

* wip

* wip

* fix

---------

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
2023-05-16 16:01:21 -04:00
Stephen Celis
79307e939f Rename WithViewStore.debug to WithViewStore._printChanges (#2101) 2023-05-12 10:06:18 -07:00
Stephen Celis
767231d179 Add Store.init that takes reducer builder (#2087)
* Add `Store.init` that takes reducer builder

* wip

* wip

* added some tests

* wip

* wip

* wip

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
2023-05-11 12:30:08 -07:00
Stephen Celis
da205c71ae Deprecate Store.scope(state:) for view store observe (#2097)
* Deprecate `Store.scope(state:)` for view store `observe`

Explicit scoping is most appropriate for transforming domains, which
almost always requires an action transform. In the rare case it doesn't,
we should prefer an explicit `{ $0 }`.

Scoping for the view has been deprecated for awhile for the `observe`
parameter when creating view stores, so let's lead folks that direction.

* wip

* wip
2023-05-11 08:17:54 -07:00
Stephen Celis
04607631de Fix ordered set comparison check (#2082)
For some reason, using `memcmp` with an empty ordered set and a
non-empty ordered set returns true:

```swift
areOrderedSetsDuplicates([1, 2, 3], [])  // true
```

Because of this, we should always check the count before delegating to
`memcmp`. We should also be on the lookout for other exceptions in case
`memcmp` is not appropriate to use here.
2023-05-04 15:09:35 -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
유재호
ce187a4d08 Update remaining 'bindable state' to 'binding state' (#2054) 2023-04-25 09:38:05 -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
Brandon Williams
d73a3494bf Better type names in WithViewStore.debug. (#1973) 2023-03-15 08:25:47 -07:00