Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Sources/ComposableArchitecture/Core.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ final class ScopedCore<Base: Core, State, Action>: Core {
let stateKeyPath: KeyPath<Base.State, State>
let actionKeyPath: CaseKeyPath<Base.Action, Action>
#if DEBUG
let isInPerceptionTracking = _PerceptionLocals.isInPerceptionTracking
let initializedInPerceptionTracking = _isInPerceptionTracking
#endif
init(
base: Base,
Expand All @@ -220,7 +220,9 @@ final class ScopedCore<Base: Core, State, Action>: Core {
@inline(__always)
var state: State {
#if DEBUG
return _PerceptionLocals.$skipPerceptionChecking.withValue(isInPerceptionTracking) {
return _PerceptionLocals.$skipPerceptionChecking.withValue(
initializedInPerceptionTracking || _isInPerceptionTracking
) {
base.state[keyPath: stateKeyPath]
}
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ extension Store where State: ObservableState {
public struct _StoreCollection<ID: Hashable & Sendable, State, Action>: RandomAccessCollection {
private let store: Store<IdentifiedArray<ID, State>, IdentifiedAction<ID, Action>>
private let data: IdentifiedArray<ID, State>
private let isInPerceptionTracking = _isInPerceptionTracking
private let initializedInPerceptionTracking = _isInPerceptionTracking

#if swift(<5.10)
@MainActor(unsafe)
Expand Down Expand Up @@ -146,7 +146,9 @@ public struct _StoreCollection<ID: Hashable & Sendable, State, Action>: RandomAc
return child
}
#if DEBUG
return _PerceptionLocals.$isInPerceptionTracking.withValue(self.isInPerceptionTracking) {
return _PerceptionLocals.$isInPerceptionTracking.withValue(
self.initializedInPerceptionTracking || _isInPerceptionTracking
) {
child
}
#else
Expand Down
2 changes: 1 addition & 1 deletion Sources/ComposableArchitecture/Store.swift
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public final class Store<State, Action>: _Store {
func subscribeToDidSet<T: ObservableState>(_ type: T.Type) -> AnyCancellable {
return core.didSet
.prefix { [weak self] _ in self?.core.isInvalid == false }
.compactMap { [weak self] in (self?.currentState as? T)?._$id }
.compactMap { [weak self] in (self?.withState(\.self) as? T)?._$id }
.removeDuplicates()
.dropFirst()
.sink { [weak self, weak parent] _ in
Expand Down
Loading