Skip to content

Commit

Permalink
[SwiftWebUI#47] replace didChange with willChange
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymon Lorenz committed Jan 10, 2020
1 parent c2a8e68 commit 1472499
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Sources/SwiftWebUI/Properties/EnvironmentObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public struct EnvironmentObject<O: ObservableObject>: _StateType {

let elementID = slot.pointee.holder.id
let context = slot.pointee.holder.context
let subscription = newValue.didChange.sink {
let subscription = newValue.willChange.sink {
[unowned context] _ in
context.invalidateComponentWithID(elementID)
}
Expand Down Expand Up @@ -93,7 +93,7 @@ public struct EnvironmentObject<O: ObservableObject>: _StateType {
fatalError("missing environment object in environment! \(O.self)")
}

let subscription = initialValue.didChange.sink {
let subscription = initialValue.willChange.sink {
[unowned context] _ in // Fishy, maybe ordering sensitive? Rather weak it?
context.invalidateComponentWithID(elementID)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftWebUI/Properties/ObservableObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public protocol ObservableObject: AnyObject, DynamicViewProperty, Identifiable {
associatedtype PublisherType : Publisher
where Self.PublisherType.Failure == Never

var didChange: Self.PublisherType { get }
var willChange: Self.PublisherType { get }

}

Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftWebUI/Properties/ObservedObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public struct ObservedObject<O: ObservableObject>: _StateType {

let elementID = slot.pointee.holder.id
let context = slot.pointee.holder.context
let subscription = newValue.didChange.sink {
let subscription = newValue.willChange.sink {
[unowned context] _ in
context.invalidateComponentWithID(elementID)
}
Expand Down Expand Up @@ -89,7 +89,7 @@ public struct ObservedObject<O: ObservableObject>: _StateType {
in context : TreeStateContext) -> StateValue
{
let typedPtr = location.assumingMemoryBound(to: Self.self)
let subscription = typedPtr.pointee._value.didChange.sink {
let subscription = typedPtr.pointee._value.willChange.sink {
[unowned context] _ in // Fishy, maybe ordering sensitive? Rather weak it?
context.invalidateComponentWithID(elementID)
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftWebUI/Views/Navigation/NavigationContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
final class NavigationContext: ObservableObject {

private(set) var activeTargetView : AnyView {
didSet { didChange.send(()) }
willSet { willChange.send(()) }
}

init(_ initialTargetView: AnyView) {
Expand All @@ -32,7 +32,7 @@ final class NavigationContext: ObservableObject {
activeTargetView = view
}

var didChange = PassthroughSubject<Void, Never>()
var willChange = PassthroughSubject<Void, Never>()
}

extension NavigationContext: CustomStringConvertible {
Expand Down

0 comments on commit 1472499

Please sign in to comment.