Commit Graph

305 Commits

Author SHA1 Message Date
Brandon Williams
c7d7d3cf1a Make sure debounced values are delivered on specified scheduler. (#714)
* Make sure debounced values are delivered on specified scheduler.

* fix deferring too

* wip
2021-08-12 17:50:47 -04:00
stephencelis
67ccab6bce Run swift-format 2021-08-11 16:13:31 +00:00
Stephen Celis
e73b36e2cb WithViewStore debug state diffs (#706)
* WithViewStore debug state diffs

* More debug checks

* fix

* wip
2021-08-11 11:55:08 -04:00
Stephen Celis
2d1e21b5aa Convert #file to #fileID for debug purposes (#708) 2021-08-11 11:54:36 -04:00
Brandon Williams
65b9f7bf07 Catch to effect updates (#707)
* Update catchToEffect docs.

* clean up
2021-08-11 11:30:55 -04:00
mbrandonw
e4a480ce9d Run swift-format 2021-08-11 15:09:43 +00:00
Eimantas
803f1b4b88 Add catchToEffect() with mapping function (#705)
Also add a couple of tests to testEraseToEffectWithError
2021-08-11 11:00:00 -04:00
Brandon Williams
bf3fc47ee8 Add some docs about ViewStore publisher. (#699)
* Add some docs about ViewStore publisher.

* clean up
2021-08-06 12:20:43 -04:00
Stephen Celis
b6ce7143cc Clarify view store thread safety (#692)
* Update ViewStore.swift

* Update ViewStore.swift

* wip

* Update ViewStore.swift
2021-08-02 11:36:28 -04:00
stephencelis
fbb931303f Run swift-format 2021-07-29 23:52:07 +00:00
Andrey
494a2a83c7 UIKit helpers generating UIAlertController from AlertState & ActionSheetState (#563)
* UIKit helpers generating UIAlertController from AlertState & ActionSheetState

* Exclude helpers from platforms not supporting UIKit (macOS)

* Exclude watchOS

* Update public API

* Update AlertStateUIKit.swift

Co-authored-by: Stephen Celis <stephen.celis@gmail.com>
2021-07-29 19:45:52 -04:00
Adam Roben
5c925e39cb Fix build error when minimum target is macOS 11.0 (#686)
macOS 11.0 introduced an overload of Publisher.flatMap(maxPublishers:_:)
for when the failure type is Never, documented here:
https://developer.apple.com/documentation/combine/publisher/flatmap(maxpublishers:_:)-qxf

This causes a compiler error in Effect.fireAndForget when the minimum
deployment target is 11.0 or later:

    Sources/ComposableArchitecture/Effect.swift:364:7: error: ambiguous use of 'flatMap(maxPublishers:_:)'
          self
          ^
    Combine.Publisher:3:17: note: found this candidate
        public func flatMap<T, P>(maxPublishers: Subscribers.Demand = .unlimited, _ transform: @escaping (Self.Output) -> P) -> Publishers.FlatMap<P, Self> where T == P.Output, P : Publisher, Self.Failure == P.Failure
                    ^
    Combine.Publisher:3:17: note: found this candidate
        public func flatMap<P>(maxPublishers: Subscribers.Demand = .unlimited, _ transform: @escaping (Self.Output) -> P) -> Publishers.FlatMap<Publishers.SetFailureType<P, Self.Failure>, Self> where P : Publisher, P.Failure == Never
                    ^

We can fix this by adding explicit type parameters to the Empty
publisher used in the flatMap().
2021-07-29 17:42:00 -04:00
Stephen Celis
68a6883045 Use modify helper in Tic-Tac-Toe integration test (#687)
* Use `modify` helper

* Clean up breakpoint warnings
2021-07-29 16:40:59 -04:00
stephencelis
b3edfcd3a4 Run swift-format 2021-07-28 18:58:37 +00:00
André Pacheco Neves
d42b471cbd Fix Effect.throttle delayed value shared state cleanup (#683)
Effect.throttle didn't clean up `throttleValues` shared state on the
delayed values path, leading to the first value strategy
(`latest: false`) to return incorrect (old) values on some scenarios.

## Changes

- Add missing `throttleValues[id]` clean up in `Effect.throttle` delayed
value path.
2021-07-28 14:50:49 -04:00
Stephen Celis
5209f47b03 Update AlertState.Button APIs for animation (#681)
* Update AlertState.Button APIs for animation

* fix

* wip

* deprecate
2021-07-28 12:10:15 -04:00
Bernhard Loibl
71be9d9676 Enables animations for alert button actions (#680)
* Enables animations for alert button actions.

* Updates alert button api and previews.

Co-authored-by: Bernhard Loibl <bernhard.loibl@intive.com>
2021-07-28 10:21:41 -04:00
stephencelis
a4f544e892 Run swift-format 2021-07-27 16:09:41 +00:00
Brandon Williams
c9653cf57b Cancel multiple effects with a variadic list. (#676)
* Cancel multiple effects with a variadic list.

* genericize

* doc fix

* use array
2021-07-26 16:05:50 -04:00
Brandon Williams
92c75a17b7 Fix typo. 2021-07-26 15:59:41 -04:00
Brandon Williams
d4c0ff35de Add an async/await aware .send method to View Store. (#673)
* wip

* case study

* docs

* clean up

* more compiler directives.

* xcode 12 fixes

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
2021-07-26 10:10:35 -04:00
konomae
60fbb66016 Fix minor typo (#671)
* Fix typo: iff → if

* Add missing `>`
2021-07-26 08:17:31 -04:00
stephencelis
b809888a5b Run swift-format 2021-07-22 17:45:38 +00:00
Stephen Celis
0978dde24a Keep last non-nil value around for ForEachStore (#668) 2021-07-22 13:32:49 -04:00
André Pacheco Neves
65f1fa043f Fix Effect.throttle data races and scheduler value return (#669)
* Fix `Effect.throttle` data races and scheduler value return

The `Effect.throttle` operator had multiple data races when updating
`throttleTimes` and `throttleValues` shared state, because:

1. `Effect.throttle` can be called from any scheduler.
2. The internal `flatMap` runs on the current chain scheduler, but the
throttled (delayed) value runs on the passed in `scheduler` parameter
(which can be different).

By protecting shared state with a lock (similar to the cancellables'),
these data races should be addressed.

Additionally, the `Effect.throttle` should return all values in the
`scheduler` passed in, so that the API contract is honored and values
come from where callers expect them to.

## Changes

- Add new `throttleLock` `recursive lock to protect `throttleTimes`
and `throttleValues` shared state in `Effect.throttle` operator.

- Ensure all values in `Effect.throttle` come from the passed in
`scheduler`.

* Fix `Effect.throttle` tests, Use `sync` lock helper
2021-07-22 13:32:36 -04:00
Olli Tapaninen
30f3027cf7 Fix IfLetStore so that it does not replay first seen state on nil-value (#667) 2021-07-22 10:31:58 -04:00
Jason Clark
a2319ff82b Buffered Actions Failing Test (#662)
* Adds a failing test demonstrating #661

* Don't write to state till `isSending` is false

* Update StoreTests.swift

* Update StoreTests.swift

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
Co-authored-by: Stephen Celis <stephen.celis@gmail.com>
2021-07-16 15:20:11 -04:00
Stephen Celis
e7dda73c35 Fix Effect.throttle (#654)
* Fix Effect.throttle

Fixes #540.

* Simplify

* Publicize
2021-07-13 11:06:51 -04:00
Stephen Celis
adb1f25ab4 Store publisher should retain its view store (#652)
* Make the StorePublisher own the ViewStore.

* cleanup

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
2021-07-12 13:25:27 -04:00
Stephen Celis
ac7ea43ff2 Merge remote-tracking branch 'origin/main' into ia 2021-07-09 15:41:49 -04:00
Stephen Celis
e900d29765 Add Benchmarking Target (#643)
* Benchmarks

* CI

* test

* fix?

* Fix
2021-07-08 15:07:49 -04:00
iampatbrown
5ca2b43bc7 Added multicast to ViewStore publisher to reduce equality checks (#624)
* Added multicast to ViewStore publisher to reduce equality checks

* Replaced multicast with ViewStore CurrentValueSubject

* Added guard check to weak self

* Clean up and add test.

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
2021-07-08 12:53:30 -04:00
stephencelis
7bdd351a07 Run swift-format 2021-07-08 15:21:45 +00:00
Stephen Celis
e4225bee93 Add test for view store state access (#642) 2021-07-08 11:14:34 -04:00
Maxim Krouk
b3cf8209ba Change ViewStore state update behavior (#634)
* fix: change ViewStore state behavior

ViewStore now takes state directly from the Store

* Run swift-format

Co-authored-by: maximkrouk <maximkrouk@users.noreply.github.com>
2021-07-08 10:53:02 -04:00
Stephen Celis
50a16e072e Deprecate array-based forEach/ForEachStore (#641)
* Deprecate array-based forEach/ForEachStore

* Update tests
2021-07-08 10:49:13 -04:00
mbrandonw
fd770f93a6 Run swift-format 2021-07-08 13:56:53 +00:00
Brandon Williams
96a4654767 Bring back deprecated IfLetStore initializer. (#638) 2021-07-08 09:47:38 -04:00
Brandon Williams
5f6d8a2538 Don't use CasePath in .binding (#632)
* Don't use CasePath in .binding

* wip

* wip

* wip
2021-07-07 18:05:43 -04:00
Stephen Celis
d5f174d4cd Remove equatable constraint from TestStore.Action (#633)
* Remove equatable constraint from TestStore.Action

It occurred to me that this is only there for testing actions received
by the store, and now that we have our simpler DSL steps for testing, we
can test simple features without ever having to worry about conforming
the action type to be equatable, or at the very least delay this
requirement a bit longer.

* fix for 11.3
2021-07-06 18:53:44 -04:00
Brandon Williams
e32172b268 Remove some old deprecated code. (#629) 2021-07-05 13:21:13 -04:00
Stephen Celis
3ca8249bd3 Coalesce synchronous effectful mutations to state (#619) 2021-06-28 07:49:37 -04:00
Stephen Celis
e7e222f1ff Store.scope/StorePublisher Performance Improvements (#616)
* Scope fix

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* revert

* wip

* wip

* wip

* fix

* wip

* wip

* wip

* wip

* wip

* wip

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
2021-06-27 21:30:43 -04:00
Stephen Celis
e1c7077cd1 wip 2021-06-25 16:42:22 -04:00
Stephen Celis
fab3510d54 wip 2021-06-25 13:06:45 -04:00
Wendy Liga
21fee722c7 Deferring Side Effect (#550)
* wip

* revert unexpected changes

* fix typo documentation

* fix another typo

* improve api

* api

* add test case

* revert

* rename to deffered

* remove delay keyword entirely

* remove unneccessary

* Update Sources/ComposableArchitecture/Effects/Deferring.swift

Co-authored-by: Stephen Celis <stephen.celis@gmail.com>
2021-06-24 09:21:03 -04:00
stephencelis
ed857eb61e Run swift-format 2021-06-21 19:10:36 +00:00
Stephen Celis
2444710eff Add more SwitchStore overloads (#607)
Goes up to 9 cases + 1 default = 10 views in a tuple.
2021-06-21 14:58:38 -04:00
Stephen Celis
d30336ca13 Clean-up pass for DocC (#599) 2021-06-16 08:48:14 -05:00
Brandon Williams
9716a3247a Improve some docs. (#597)
* Improve some docs.

* wip

* Update Sources/ComposableArchitecture/Store.swift

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

* Update Sources/ComposableArchitecture/Store.swift

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

* Update Sources/ComposableArchitecture/Store.swift

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

* Update Sources/ComposableArchitecture/Store.swift

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

* Update Sources/ComposableArchitecture/Store.swift

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

* Update Sources/ComposableArchitecture/Store.swift

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

* Update Sources/ComposableArchitecture/ViewStore.swift

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

* 110 column

* update link

* add docc to switchstore

Co-authored-by: Stephen Celis <stephen@stephencelis.com>
2021-06-15 10:33:52 -04:00