Skip to content

Commit

Permalink
Merge pull request #41 from AckeeCZ/update_reactive
Browse files Browse the repository at this point in the history
Update reactive dependencies
  • Loading branch information
janmisar authored May 2, 2019
2 parents c18ac54 + 2fab9d0 commit 6818bab
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 49 deletions.
4 changes: 2 additions & 2 deletions ACKReactiveExtensions.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Pod::Spec.new do |s|
s.ios.deployment_target = '8.3'
s.swift_version = '5.0'
s.default_subspec = 'Core','UIKit'
s.dependency 'ReactiveCocoa', '~> 9.0'
s.dependency 'ReactiveSwift', '~> 5.0'
s.dependency 'ReactiveCocoa', '~> 10.0'
s.dependency 'ReactiveSwift', '~> 6.0'

s.subspec 'Core' do |core|
core.source_files = 'ACKReactiveExtensions/Core/*.swift'
Expand Down
6 changes: 0 additions & 6 deletions ACKReactiveExtensions.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

/* Begin PBXBuildFile section */
690C440F2141870000C39F46 /* UIImageViewExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 690C440D214186E600C39F46 /* UIImageViewExtensions.swift */; };
691DCED421105D5300F5C06A /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 699B58F01FF52E2D00FFDC91 /* Result.framework */; };
691F8596202A106600DA4FAD /* UIControlExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 691F8595202A106600DA4FAD /* UIControlExtensions.swift */; };
6925243F20D14EC300228289 /* UIViewControllerExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6925243D20D14E7100228289 /* UIViewControllerExtensions.swift */; };
69470C64200763C00013A386 /* ActionExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69470C63200763C00013A386 /* ActionExtensions.swift */; };
Expand All @@ -22,7 +21,6 @@
699B58E51FF5289A00FFDC91 /* RealmExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 699B58E41FF5289A00FFDC91 /* RealmExtensions.swift */; };
699B58EB1FF52DCC00FFDC91 /* TextfieldBinding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 699B58E91FF52DCC00FFDC91 /* TextfieldBinding.swift */; };
699B58ED1FF52DD700FFDC91 /* WKWebViewExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 699B58EC1FF52DD600FFDC91 /* WKWebViewExtensions.swift */; };
699B58F31FF52E2D00FFDC91 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 699B58F01FF52E2D00FFDC91 /* Result.framework */; };
699B58F41FF52E2D00FFDC91 /* ReactiveCocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 699B58F11FF52E2D00FFDC91 /* ReactiveCocoa.framework */; };
699B58F51FF52E2D00FFDC91 /* ReactiveSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 699B58F21FF52E2D00FFDC91 /* ReactiveSwift.framework */; };
699B58F81FF52F0600FFDC91 /* ACKReactiveExtensionsCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 699B583F1FF526A000FFDC91 /* ACKReactiveExtensionsCore.framework */; };
Expand All @@ -33,7 +31,6 @@
699B59191FF5305F00FFDC91 /* Realm.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 699B59171FF5305F00FFDC91 /* Realm.framework */; };
699B59211FF53DA900FFDC91 /* ReactiveCocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 699B58F11FF52E2D00FFDC91 /* ReactiveCocoa.framework */; };
699B59241FF53DC300FFDC91 /* RealmSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 699B59161FF5305F00FFDC91 /* RealmSwift.framework */; };
699B59251FF53DDB00FFDC91 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 699B58F01FF52E2D00FFDC91 /* Result.framework */; };
699B59261FF5434E00FFDC91 /* ReactiveSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 699B58F21FF52E2D00FFDC91 /* ReactiveSwift.framework */; };
699B59271FF5437300FFDC91 /* ReactiveSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 699B58F21FF52E2D00FFDC91 /* ReactiveSwift.framework */; };
699C4F872083892300AEEAA1 /* UITableViewExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 699C4F862083892300AEEAA1 /* UITableViewExtensions.swift */; };
Expand Down Expand Up @@ -134,7 +131,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
699B58F31FF52E2D00FFDC91 /* Result.framework in Frameworks */,
699B58F41FF52E2D00FFDC91 /* ReactiveCocoa.framework in Frameworks */,
699B58F51FF52E2D00FFDC91 /* ReactiveSwift.framework in Frameworks */,
);
Expand All @@ -153,7 +149,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
691DCED421105D5300F5C06A /* Result.framework in Frameworks */,
699B59271FF5437300FFDC91 /* ReactiveSwift.framework in Frameworks */,
699B58F91FF52F0E00FFDC91 /* ACKReactiveExtensionsCore.framework in Frameworks */,
);
Expand All @@ -172,7 +167,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
699B59251FF53DDB00FFDC91 /* Result.framework in Frameworks */,
699B59241FF53DC300FFDC91 /* RealmSwift.framework in Frameworks */,
699B59211FF53DA900FFDC91 /* ReactiveCocoa.framework in Frameworks */,
699B59191FF5305F00FFDC91 /* Realm.framework in Frameworks */,
Expand Down
2 changes: 1 addition & 1 deletion ACKReactiveExtensions/Core/ActionExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extension Action {
.flatMap(.latest) { isExecuting, isEnabled -> SignalProducer<Output, Error> in
switch (isExecuting, isEnabled) {
case (true, _): return events.dematerialize().producer
case (false, false): return SignalProducer<Output, Error>.interrupted()
case (false, false): return SignalProducer<Output, Never>.interrupted().promoteError()
case (false, true): return events.dematerialize().producer
}
}
Expand Down
13 changes: 6 additions & 7 deletions ACKReactiveExtensions/Core/Core.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import Result
import ReactiveSwift

extension SignalProducer {
/// Ignore errors and return SignalProducer that completes instead of error
public func ignoreError() -> SignalProducer<Value, NoError> {
public func ignoreError() -> SignalProducer<Value, Never> {
return flatMapError { _ in .empty }
}

/// Create interrupted producer
public static func interrupted() -> SignalProducer<Value, Error> {
return SignalProducer<Value, Error> { observer, _ in
public static func interrupted() -> SignalProducer<Value, Never> {
return SignalProducer<Value, Never> { observer, _ in
observer.sendInterrupted()
}
}
Expand All @@ -23,10 +22,10 @@ extension Signal {
}
}

extension SignalProducer where Value == Void, Error == NoError {
extension SignalProducer where Value == Void, Error == Never {
/// Perform side effect
public static func sideEffect(actions: @escaping () -> ()) -> SignalProducer<(), NoError> {
return SignalProducer<(), NoError> { sink, _ in
public static func sideEffect(actions: @escaping () -> ()) -> SignalProducer<(), Never> {
return SignalProducer<(), Never> { sink, _ in
actions()
sink.sendCompleted()
}
Expand Down
27 changes: 14 additions & 13 deletions ACKReactiveExtensions/Marshal/MarshalMapping.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Ackee
//

import Result
import Marshal
import ReactiveSwift

Expand Down Expand Up @@ -57,7 +56,7 @@ extension Signal where Value == Any, Error: MarshalErrorCreatable {
return try Model.init(object: marshaledJSON)
}
})
.mapError { Error.createMarshalError($0) }
.mapError { Error.createMarshalError($0 as! MarshalError) }
}
}

Expand All @@ -68,22 +67,24 @@ extension Signal where Value == Any, Error: MarshalErrorCreatable {
*/
public func mapResponse<Model>(forKey key: KeyType? = nil) -> Signal<[Model], Error> where Model: Unmarshaling {
return signal.attemptMap { json in
Result(catching: {
return Result(catching: {
if ACKReactiveExtensionsConfiguration.allowMappingOnMainThread == false {
assert(Thread.current.isMainThread == false, "Mapping should not be performed on main thread!")
}

if let key = key, let marshaledJSON = json as? MarshaledObject {
return try marshaledJSON.value(for: key)
}
else if let marshaledArray = json as? [MarshaledObject] {
return try marshaledArray.map(Model.init)
}
else {
throw MarshalError.typeMismatch(expected: MarshaledObject.self, actual: type(of: json))
do {
if let key = key, let marshaledJSON = json as? MarshaledObject {
return try marshaledJSON.value(for: key)
}
else if let marshaledArray = json as? [MarshaledObject] {
return try marshaledArray.map(Model.init)
}
else {
throw MarshalError.typeMismatch(expected: MarshaledObject.self, actual: type(of: json))
}
}
})
.mapError { Error.createMarshalError($0) }
.mapError { Error.createMarshalError($0 as! MarshalError) }
}
}

Expand All @@ -105,7 +106,7 @@ extension Signal where Value == Any, Error: MarshalErrorCreatable {
}
return try marshaledJSON.value(for: key)
})
.mapError { Error.createMarshalError($0) }
.mapError { Error.createMarshalError($0 as! MarshalError) }
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions ACKReactiveExtensions/UIKit/TextfieldBinding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ public func <~> (textField: UITextField, property: MutableProperty<String?>) {
/// If `textField` sends `nil` value then it is mapped to an empty string
public func <~> (property: MutableProperty<String>, textField: UITextField) {
textField.reactive.text <~ property.producer.observe(on: UIScheduler()).filter { [unowned textField] in textField.text != $0 }
property <~ textField.reactive.continuousTextValues.map { $0 ?? "" }
property <~ textField.reactive.continuousTextValues
}

/// Binds given `property` to continousValues of given `textField`
/// If `textField` sends `nil` value then it is mapped to an empty string
public func <~> (textField: UITextField, property: MutableProperty<String>) {
textField.reactive.text <~ property.producer.observe(on: UIScheduler()).filter { [unowned textField] in textField.text != $0 }
property <~ textField.reactive.continuousTextValues.map { $0 ?? "" }
property <~ textField.reactive.continuousTextValues
}

/// Binds given `property` to continousValues of given `textView`
Expand All @@ -53,12 +53,12 @@ public func <~> (textView: UITextView, property: MutableProperty<String?>) {
/// If `textView` sends `nil` value then it is mapped to an empty string
public func <~> (textView: UITextView, property: MutableProperty<String>) {
textView.reactive.text <~ property.producer.observe(on: UIScheduler()).filter { [unowned textView] in textView.text != $0 }
property <~ textView.reactive.continuousTextValues.map { $0 ?? "" }
property <~ textView.reactive.continuousTextValues
}

/// Binds given `property` to continousValues of given `textView`
/// If `textView` sends `nil` value then it is mapped to an empty string
public func <~> (property: MutableProperty<String>, textView: UITextView) {
textView.reactive.text <~ property.producer.observe(on: UIScheduler()).filter { [unowned textView] in textView.text != $0 }
property <~ textView.reactive.continuousTextValues.map { $0 ?? "" }
property <~ textView.reactive.continuousTextValues
}
3 changes: 1 addition & 2 deletions ACKReactiveExtensions/UIKit/UIControlExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
//

import UIKit
import Result
import ReactiveSwift

extension Reactive where Base: UIControl {
public var valueChanged: Signal<Base, NoError> {
public var valueChanged: Signal<Base, Never> {
return controlEvents(.valueChanged)
}
}
3 changes: 1 addition & 2 deletions ACKReactiveExtensions/UIKit/UIImageViewExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@

import UIKit
import ReactiveSwift
import enum Result.NoError

extension Reactive where Base: UIImageView {
public var imageSignal: Signal<UIImage?, NoError> {
public var imageSignal: Signal<UIImage?, Never> {
return signal(forKeyPath: "image").map { $0 as? UIImage }
}
}
7 changes: 3 additions & 4 deletions ACKReactiveExtensions/UIKit/UIViewExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import UIKit
import Result
import ReactiveSwift

extension Reactive where Base: UIView {
Expand All @@ -15,7 +14,7 @@ extension Reactive where Base: UIView {
return Property(initial: base.isHidden, then: isHiddenSignal)
}

private var isHiddenSignal: Signal<Bool, NoError> {
private var isHiddenSignal: Signal<Bool, Never> {
return signal(forKeyPath: "hidden").map { $0 as? Bool }.skipNil()
}

Expand All @@ -41,11 +40,11 @@ extension Reactive where Base: UIView {
return Property(initial: base.bounds, then: boundsSignal)
}

private var frameSignal: Signal<CGRect, NoError> {
private var frameSignal: Signal<CGRect, Never> {
return signal(forKeyPath: "frame").filterMap { $0 as? CGRect }
}

private var boundsSignal: Signal<CGRect, NoError> {
private var boundsSignal: Signal<CGRect, Never> {
return signal(forKeyPath: "bounds").filterMap { $0 as? CGRect }
}
}
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

## master

- update ReactiveSwift & ReactiveCocoa, use native Result (#41, kudos to @olejnjak)

## 4.1

- migrate to Xcode 10.2 and Swift 5 (#39, kudos to @olejnjak)
Expand Down
5 changes: 2 additions & 3 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
github "ReactiveCocoa/ReactiveCocoa" ~> 9.0
github "ReactiveCocoa/ReactiveSwift" ~> 5.0
github "antitypical/Result" ~> 4.1
github "ReactiveCocoa/ReactiveCocoa" ~> 10.0
github "ReactiveCocoa/ReactiveSwift" ~> 6.0
github "realm/realm-cocoa" ~> 3.14
github "utahiosmac/Marshal" ~> 1.2
github "Alamofire/AlamofireImage" ~> 3.3
9 changes: 4 additions & 5 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
github "Alamofire/Alamofire" "4.8.2"
github "Alamofire/AlamofireImage" "3.5.1"
github "ReactiveCocoa/ReactiveCocoa" "9.0.0"
github "ReactiveCocoa/ReactiveSwift" "5.0.0"
github "antitypical/Result" "4.1.0"
github "realm/realm-cocoa" "v3.14.0"
github "Alamofire/AlamofireImage" "3.5.2"
github "ReactiveCocoa/ReactiveCocoa" "10.0.0"
github "ReactiveCocoa/ReactiveSwift" "6.0.0"
github "realm/realm-cocoa" "v3.14.2"
github "utahiosmac/Marshal" "1.2.7"

0 comments on commit 6818bab

Please sign in to comment.