Skip to content

Commit

Permalink
Simplify Store
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimillian committed Jul 18, 2019
1 parent 5fc4ddb commit 6ed0743
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Sources/SwiftUIFlux/Store.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import SwiftUI
import Combine

final public class Store<State: FluxState>: BindableObject {
public let willChange = PassthroughSubject<State, Never>()
public let willChange = PassthroughSubject<Void, Never>()

private(set) public var state: State

Expand Down Expand Up @@ -43,9 +43,7 @@ final public class Store<State: FluxState>: BindableObject {
}

private func _dispatch(action: Action) {
DispatchQueue.main.async {
self.willChange.send(self.state)
self.state = self.reducer(self.state, action)
}
willChange.send()
state = reducer(state, action)
}
}

0 comments on commit 6ed0743

Please sign in to comment.