From 1a1295f226cb61925c545e3980b4ee771103463f Mon Sep 17 00:00:00 2001 From: Pavel Sharanda Date: Thu, 21 Sep 2017 22:45:16 +0300 Subject: [PATCH] back to non optional flatMapLatest --- Sources/Observable+FlatMap.swift | 8 ++++---- Sources/Observable+Task.swift | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/Observable+FlatMap.swift b/Sources/Observable+FlatMap.swift index 41657a4..6c369e4 100644 --- a/Sources/Observable+FlatMap.swift +++ b/Sources/Observable+FlatMap.swift @@ -8,23 +8,23 @@ import Foundation extension ObservableProtocol { - public func flatMapLatest(_ f: @escaping ((ValueType) -> Observable?)) -> Observable { + public func flatMapLatest(_ f: @escaping ((ValueType) -> Observable)) -> Observable { return Observable { observer in let serial = SwapableDisposable() serial.swap(parent: self.subscribe { result in serial.disposeChild() - serial.swap(child: f(result)?.subscribe(observer)) + serial.swap(child: f(result).subscribe(observer)) }) return serial } } - public func flatMapMerge(_ f: @escaping ((ValueType) -> Observable?)) -> Observable { + public func flatMapMerge(_ f: @escaping ((ValueType) -> Observable)) -> Observable { return Observable { observer in let multi = MultiDisposable() multi.add(self.subscribe { result in - multi.add(f(result)?.subscribe(observer)) + multi.add(f(result).subscribe(observer)) }) return multi } diff --git a/Sources/Observable+Task.swift b/Sources/Observable+Task.swift index 87e1077..8045899 100644 --- a/Sources/Observable+Task.swift +++ b/Sources/Observable+Task.swift @@ -9,7 +9,7 @@ extension ObservableProtocol where ValueType: ResultConvertible { public typealias ResultValueType = ValueType.ValueType - public func flatMapLatestValue(_ f: @escaping (ResultValueType)->Task?) -> Task { + public func flatMapLatestValue(_ f: @escaping (ResultValueType)->Task) -> Task { return flatMapLatest { result in switch result.result { case .success(let value): @@ -20,7 +20,7 @@ extension ObservableProtocol where ValueType: ResultConvertible { } } - public func flatMapMergeValue(_ f: @escaping (ResultValueType)->Task?) -> Task { + public func flatMapMergeValue(_ f: @escaping (ResultValueType)->Task) -> Task { return flatMapMerge { result in switch result.result { case .success(let value):