Skip to content

Conversation

@fpillet
Copy link
Member

@fpillet fpillet commented Sep 4, 2017

Added .rx.action for macOS NSControl and NSButton, ported tests to match on platform.

@fpillet
Copy link
Member Author

fpillet commented Sep 5, 2017

Hrm tests are "failing" (passing actually but with a compilation warning) because of an issue in InputSubject I didn't introduce -- it was already producing a warning. Will submit a separate PR to fix it

@ashfurrow
Copy link
Member

Thanks @fpillet ! Let us know what we can do to assist.

@fpillet
Copy link
Member Author

fpillet commented Sep 7, 2017

After investigation, it wasn't InputSubject warnings but the fact that I split test files in separate folders for macOS and iOS -- Travis want them suffixed with Tests otherwise it doesn't like it.

This is fixed now. Please merge at your convenience.

Copy link
Member

@freak4pc freak4pc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really good change ! I'm all for.
Got some notes I think worth discussing around unifying the code for the different OS-level implementation details

import RxCocoa
import ObjectiveC

public extension Reactive where Base: NSButton {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a huge fan of this repetition... What about using OS-specific button aliases ?

e.g. something like

#if os(iOS)
    import UIKit
    typealias OSButton = UIButton
#elseif os(macOS)
    import Cocoa
    import AppKit
    typealias OSButton = NSButton
#endif

extension Reactive where Base: OSButton {

}

Makes even more sense due to the fact it seems this is already done for tvOS: https://github.com/fpillet/Action/blob/896866a30c879089e740d2a94b29bca62cc9eb53/Sources/Action/UIKitExtensions/UIButton%2BRx.swift#L36

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS and tvOS have UIButton in common. macOS NSButton has some code differences -- it only have one target, not multiple, so you'll see the code is not the same

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah for sure, but I still think there is room for condition? The differences, I think, are relatively minor IIRC

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are plenty other macOS controls that don't exist on iOS and we'll have to add support for (I'm currently using NSStepper and NSPopUpButton a lot and would eventually like to include Action support for them as well). I think it wouldn't make sense to share just one class, it's cleaner to have separate code bases because most of the controls are too diverging

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I definitely don't have a deep enough understanding of macOS to feel very religious about this :) If it makes sense for you let's go with it. There are some styling issues at the bottom (indent and excess void) that could be worth addressing

import RxSwift
import RxCocoa

public extension Reactive where Base: NSControl {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, could be

#if os(iOS)
    import UIKit
    typealias OSControl = UIControl
#elseif os(macOS)
    import Cocoa
    import AppKit
    typealias OSControl = NSControl
#endif

extension Reactive where Base: OSControl {

}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somewhat agree on this one, the base control is relatively agnostic


scheduler.scheduleAt(30) {
trigger.onNext()
#if swift(>=3.2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the separate handling? Wouldn't trigger.onNext(()) work across both ?

also, nit: Indentation looks off here

@nightfall708
Copy link

+1 On this PR! 👊👊👊

@ashfurrow
Copy link
Member

One of the xcoidebuild commands failed with the intermittent Error 65. Since all the tests that ran passed, I'm going to merge. Thanks a lot for your hard work! Would you like to take care of making a release? I've added you as an owner on CocoaPods trunk, but I'm happy to do it :)

@ashfurrow ashfurrow merged commit 90d1806 into RxSwiftCommunity:master Sep 12, 2017
@fpillet
Copy link
Member Author

fpillet commented Sep 12, 2017

@ashfurrow thanks! will make a new release today.

@ashfurrow ashfurrow mentioned this pull request Sep 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants