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().
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.
* 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
* 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>
* 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>
* 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>
* 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