Skip to content

Commit

Permalink
refactor: Rename forceUpdateIfNeeded() to forceUpdate() for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
dankinsoid committed Dec 18, 2024
1 parent a33fd12 commit 1dc0787
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
7 changes: 1 addition & 6 deletions Sources/VDStore/Store.swift
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public struct Store<State>: Sendable {
try await StoreDIValues.$current.withValue(diModifier, operation: operation)
}

func forceUpdateIfNeeded() {
func forceUpdate() {
box.forceUpdate()
}
}
Expand Down Expand Up @@ -381,8 +381,3 @@ private extension Store {
DIPublisher(base: publisher, modifier: diModifier).eraseToAnyPublisher()
}
}

extension Store: Identifiable where State: Identifiable {

public var id: State.ID { state.id }
}
2 changes: 1 addition & 1 deletion Sources/VDStore/StoreExtensions/WithAnimaiton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public extension Store {
func withAnimation<T>(_ animation: Animation? = .default, _ operation: @MainActor () throws -> T) rethrows -> T {
try SwiftUI.withAnimation(animation) {
let result = try update(operation)
forceUpdateIfNeeded()
forceUpdate()
return result
}
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/VDStore/Utils/StoreBox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct StoreBox<Output>: Publisher, Sendable {

func startUpdate() { root.startUpdate() }
func endUpdate() { root.endUpdate() }
func forceUpdate() { root.forceUpdateIfNeeded() }
func forceUpdate() { root.forceUpdate() }

func receive<S>(subscriber: S) where S: Subscriber, Never == S.Failure, Output == S.Input {
valuePublisher.receive(subscriber: subscriber)
Expand All @@ -54,7 +54,7 @@ private protocol StoreRootBoxType: Sendable {
var willSetPublisher: AnyPublisher<Void, Never> { get }
func startUpdate()
func endUpdate()
func forceUpdateIfNeeded()
func forceUpdate()
}

private final class StoreRootBox<State>: StoreRootBoxType, Publisher, @unchecked Sendable {
Expand Down Expand Up @@ -131,7 +131,7 @@ private final class StoreRootBox<State>: StoreRootBoxType, Publisher, @unchecked
}
}

func forceUpdateIfNeeded() {
func forceUpdate() {
guard updatesCounter > 0 || asyncUpdatesCounter > 0 else { return }
sendDidSet()
sendWillSet()
Expand Down

0 comments on commit 1dc0787

Please sign in to comment.