Skip to content

Commit

Permalink
Amend dispatch to return a subscription reference
Browse files Browse the repository at this point in the history
  • Loading branch information
Qata committed Feb 15, 2018
1 parent 91ea6d8 commit be1ac7a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#Upcoming Release

#4.0.1
**API Changes:**

- `dispatch(_ stream:)` now returns a subscription reference.

#3.0.6
**Breaking API Changes:**

Expand Down
7 changes: 5 additions & 2 deletions Sources/CoreTypes/Store.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ open class Store<ObservableProperty: ObservablePropertyType> {
}
}

public func dispatch<S: StreamType>(_ stream: S) where S.ValueType: Action {
disposeBag += stream.subscribe { [unowned self] action in
@discardableResult
public func dispatch<S: StreamType>(_ stream: S) -> SubscriptionReferenceType? where S.ValueType: Action {
let disposable = stream.subscribe { [unowned self] action in
self.dispatch(action)
}
disposeBag += disposable
return disposable
}
}

0 comments on commit be1ac7a

Please sign in to comment.