Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
Remove duplicates when propagating state (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
reddavis authored Jun 10, 2022
1 parent aad29dc commit 7d2c96a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion RedUx/Source/Store.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import SwiftUI
/// Generally an application will have one store and then use the scope function to create sub stores for
/// different components of the app.
@MainActor
public final class Store<State, Event, Environment> {
public final class Store<State, Event, Environment> where State: Equatable {
/// The state of the store.
public private(set) var state: State {
didSet {
Expand Down Expand Up @@ -153,6 +153,7 @@ extension Store {

// Propagate changes to state to scoped store.
scopedStore.parentStatePropagationTask = self.stateSequence
.removeDuplicates()
.sink(priority: .high) { [weak scopedStore] in
scopedStore?.state = toScopedState($0)
}
Expand Down
3 changes: 2 additions & 1 deletion RedUx/Source/SwiftUI/UnwrapStore.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import SwiftUI

@MainActor
public struct UnwrapStore<State, Event, Environment, Content>: View where Content: View {
public struct UnwrapStore<State, Event, Environment, Content>: View
where Content: View, State: Equatable {
private let content: (Store<State?, Event, Environment>) -> Content
private let store: Store<State?, Event, Environment>

Expand Down

0 comments on commit 7d2c96a

Please sign in to comment.