Skip to content

Commit

Permalink
Update API for beta 4 of API
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenLambion committed Jul 20, 2019
1 parent a2e5ac1 commit 870df63
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Sources/SwiftDux/UI/DispatcherContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import Combine
///
/// Typically you should use the `Store<_>.connect(updateOn:wrapper:)` method.
public class DispatcherContext : BindableObject {
public var didChange = PassthroughSubject<Void, Never>()
public var willChange = PassthroughSubject<Void, Never>()
var dispatcher: ActionDispatcher {
didSet { didChange.send() }
willSet { willChange.send() }
}

init(dispatcher: ActionDispatcher) {
Expand Down
6 changes: 3 additions & 3 deletions Sources/SwiftDux/UI/Extensions/View+AppearanceEvents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ extension View {
/// This includes changes to the application state from dispatched actions. This method
/// allows actions to be dispatched when the view appears.
/// - Parameter perform: The action to run asynchronously
public func onAppearAsync(perform: @escaping () -> ()) -> Self.Modified<_AppearanceActionModifier> {
public func onAppearAsync(perform: @escaping () -> ()) -> some View {
return self.onAppear {
DispatchQueue.main.async(execute: perform)
}
}

/// Performs an action asynchronously on the main thread when a view appears.
/// - Parameter perform: The action to run asynchronously
public func onDisappearAsync(perform: @escaping () -> ()) -> Self.Modified<_AppearanceActionModifier> {
return self.onDisappear() {
public func onDisappearAsync(perform: @escaping () -> ()) -> some View {
return self.onDisappear {
DispatchQueue.main.async(execute: perform)
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftDux/UI/StateContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Combine
import SwiftUI

internal class StateContext<State> : BindableObject where State : StateType {
var didChange = PassthroughSubject<Action, Never>()
var willChange = PassthroughSubject<Action, Never>()

var filter: (Action) -> Bool

Expand All @@ -18,7 +18,7 @@ internal class StateContext<State> : BindableObject where State : StateType {
guard oldValue !== store else { return }
guard let store = store else { return }
let didChangePublisher = store.didChange.filter(filter)
cancellable = didChangePublisher.subscribe(didChange)
cancellable = didChangePublisher.subscribe(willChange)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftDux/UI/StoreContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import SwiftUI
import Combine

public class StoreContext<State> : BindableObject where State : StateType {
public var didChange = Publishers.Empty<Void, Never>()
public var willChange = Empty<Void, Never>()
public var store: Store<State>

init(store: Store<State>) {
Expand Down

0 comments on commit 870df63

Please sign in to comment.