Skip to content

Commit

Permalink
Fix perception warnings (pointfreeco#2849)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis committed Feb 26, 2024
1 parent b8b726c commit 591f1a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Sources/ComposableArchitecture/Store.swift
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,11 @@ public final class Store<State, Action> {
/// it conforms to ``ObservableState``.
/// - Returns: The return value, if any, of the `body` closure.
public func withState<R>(_ body: (_ state: State) -> R) -> R {
body(self.currentState)
#if canImport(Perception)
_withoutPerceptionChecking { body(self.currentState) }
#else
body(self.currentState)
#endif
}

/// Sends an action to the store.
Expand Down
4 changes: 2 additions & 2 deletions Sources/ComposableArchitecture/ViewStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ public final class ViewStore<ViewState, ViewAction>: ObservableObject {
action: fromViewAction,
isInvalid: nil
)
self._state = CurrentValueRelay(self.store.currentState)
self._state = CurrentValueRelay(self.store.withState { $0 })
self.viewCancellable = self.store.rootStore.didSet
.compactMap { [weak self] in self?.store.currentState }
.compactMap { [weak self] in self?.store.withState { $0 } }
.removeDuplicates(by: isDuplicate)
.dropFirst()
.sink { [weak self] in
Expand Down

0 comments on commit 591f1a4

Please sign in to comment.