Created
July 15, 2018 18:22
-
-
Save twittemb/54b5d63abfd557813fba03b9b8cb2f65 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public func dispatch (action: Action) { | |
| // every received action is converted to an async action | |
| action | |
| .toAsync() | |
| .map { [unowned self] (action) -> StateType? in | |
| return self.reducers.reduce(self.state.value, { (state, reducer) -> StateType? in | |
| return reducer(state, action) | |
| }) | |
| }.subscribe(onNext: { [unowned self] (newState) in | |
| self.state.accept(newState) | |
| }).disposed(by: self.disposeBag) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment