From be1ac7aed71adccb30118bb1ff38b6af9f54bdbf Mon Sep 17 00:00:00 2001 From: Charlotte Tortorella Date: Thu, 15 Feb 2018 16:51:47 +1100 Subject: [PATCH] Amend dispatch to return a subscription reference --- CHANGELOG.md | 5 +++++ Sources/CoreTypes/Store.swift | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84345b7..32ac7c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ #Upcoming Release +#4.0.1 +**API Changes:** + +- `dispatch(_ stream:)` now returns a subscription reference. + #3.0.6 **Breaking API Changes:** diff --git a/Sources/CoreTypes/Store.swift b/Sources/CoreTypes/Store.swift index cdb32a3..97619d4 100644 --- a/Sources/CoreTypes/Store.swift +++ b/Sources/CoreTypes/Store.swift @@ -35,9 +35,12 @@ open class Store { } } - public func dispatch(_ stream: S) where S.ValueType: Action { - disposeBag += stream.subscribe { [unowned self] action in + @discardableResult + public func dispatch(_ stream: S) -> SubscriptionReferenceType? where S.ValueType: Action { + let disposable = stream.subscribe { [unowned self] action in self.dispatch(action) } + disposeBag += disposable + return disposable } }