Skip to content

Commit

Permalink
Updating spm syntax to new swift-tools (#192)
Browse files Browse the repository at this point in the history
* Upating dependencies to Rx 4.5.0

* Reverting version.

* From 4.0.0 on package

* Apply suggestions from code review
  • Loading branch information
LucianoPAlmeida authored and bobgodwinx committed Apr 12, 2019
1 parent a05dd0b commit 2a757a8
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ Carthage
# SPM
#
Packages
.build
16 changes: 16 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"object": {
"pins": [
{
"package": "RxSwift",
"repositoryURL": "https://github.com/ReactiveX/RxSwift.git",
"state": {
"branch": null,
"revision": "12cccb171ad9038251af6883807f0290c1d75a5b",
"version": "4.0.0"
}
}
]
},
"version": 1
}
20 changes: 17 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
// swift-tools-version:5.0

import PackageDescription

let package = Package(
name: "Action",
targets: [],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "Action",
targets: ["Action"]),
],
dependencies: [
.Package(url: "https://github.com/ReactiveX/RxSwift.git", Version(4, 0, 0, prereleaseIdentifiers: ["alpha.1"]))
.package(url: "https://github.com/ReactiveX/RxSwift.git", from: "4.0.0")
],
exclude: ["Tests/"]
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "Action",
dependencies: ["RxSwift", "RxCocoa"],
path: "Sources/Action")
]
)

6 changes: 3 additions & 3 deletions Sources/Action/UIKitExtensions/UIAlertAction+Action.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public typealias ActionStyle = UIAlertActionStyle

public extension UIAlertAction {

public static func Action(_ title: String?, style: ActionStyle) -> UIAlertAction {
static func Action(_ title: String?, style: ActionStyle) -> UIAlertAction {
return UIAlertAction(title: title, style: style, handler: { action in
action.rx.action?.execute()
return
Expand All @@ -24,7 +24,7 @@ public extension Reactive where Base: UIAlertAction {
/// Binds enabled state of action to button, and subscribes to rx_tap to execute action.
/// These subscriptions are managed in a private, inaccessible dispose bag. To cancel
/// them, set the rx.action to nil or another action.
public var action: CocoaAction? {
var action: CocoaAction? {
get {
var action: CocoaAction?
action = objc_getAssociatedObject(base, &AssociatedKeys.Action) as? Action
Expand All @@ -48,7 +48,7 @@ public extension Reactive where Base: UIAlertAction {
}
}

public var enabled: AnyObserver<Bool> {
var enabled: AnyObserver<Bool> {
return AnyObserver { [weak base] event in
MainScheduler.ensureExecutingOnScheduler()

Expand Down
8 changes: 4 additions & 4 deletions Sources/Action/UIKitExtensions/UIBarButtonItem+Action.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public extension Reactive where Base: UIBarButtonItem {
/// Binds enabled state of action to bar button item, and subscribes to rx_tap to execute action.
/// These subscriptions are managed in a private, inaccessible dispose bag. To cancel
/// them, set the rx.action to nil or another action.
public var action: CocoaAction? {
var action: CocoaAction? {
get {
var action: CocoaAction?
action = objc_getAssociatedObject(self.base, &AssociatedKeys.Action) as? Action
Expand Down Expand Up @@ -38,7 +38,7 @@ public extension Reactive where Base: UIBarButtonItem {
}
}

public func bind<Input, Output>(to action: Action<Input, Output>, inputTransform: @escaping (Base) -> (Input)) {
func bind<Input, Output>(to action: Action<Input, Output>, inputTransform: @escaping (Base) -> (Input)) {
unbindAction()

self.tap
Expand All @@ -52,12 +52,12 @@ public extension Reactive where Base: UIBarButtonItem {
.disposed(by: self.base.actionDisposeBag)
}

public func bind<Input, Output>(to action: Action<Input, Output>, input: Input) {
func bind<Input, Output>(to action: Action<Input, Output>, input: Input) {
self.bind(to: action) { _ in input}
}

/// Unbinds any existing action, disposing of all subscriptions.
public func unbindAction() {
func unbindAction() {
self.base.resetActionDisposeBag()
}
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/Action/UIKitExtensions/UIRefreshControl+Action.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public extension Reactive where Base: UIRefreshControl {
// These subscriptions are managed in a private, inaccessible dispose bag. To cancel
// them, set the rx.action to nil or another action.

public var action: CocoaAction? {
var action: CocoaAction? {
get {
var action: CocoaAction?
action = objc_getAssociatedObject(base, &AssociatedKeys.Action) as? Action
Expand All @@ -30,7 +30,7 @@ public extension Reactive where Base: UIRefreshControl {
}
}

public func bind<Input, Output>(to action: Action<Input, Output>, inputTransform: @escaping (Base) -> (Input)) {
func bind<Input, Output>(to action: Action<Input, Output>, inputTransform: @escaping (Base) -> (Input)) {
unbindAction()

self.controlEvent(.valueChanged)
Expand All @@ -49,12 +49,12 @@ public extension Reactive where Base: UIRefreshControl {
.disposed(by: self.base.actionDisposeBag)
}

public func bind<Input, Output>(to action: Action<Input, Output>, input: Input) {
func bind<Input, Output>(to action: Action<Input, Output>, input: Input) {
self.bind(to: action) { _ in input}
}

/// Unbinds any existing action, disposing of all subscriptions.
public func unbindAction() {
func unbindAction() {
self.base.resetActionDisposeBag()
}
}
Expand Down

0 comments on commit 2a757a8

Please sign in to comment.