Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve naming of public API properties #126

Merged
merged 5 commits into from
Jan 8, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Demo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class ViewController: UIViewController {
// Demo: observe the output of both actions, spin an activity indicator
// while performing the work
Observable.combineLatest(
button.rx.action!.executing,
self.navigationItem.rightBarButtonItem!.rx.action!.executing) { a,b in
button.rx.action!.isExecuting,
self.navigationItem.rightBarButtonItem!.rx.action!.isExecuting) { a,b in
// we combine two boolean observable and output one boolean
return a || b
}
Expand All @@ -90,7 +90,7 @@ class ViewController: UIViewController {
}
self.navigationItem.leftBarButtonItem?.rx.bind(to: sharedAction, input: .barButton)

sharedAction.executing.debounce(0, scheduler: MainScheduler.instance).subscribe(onNext: { [weak self] executing in
sharedAction.isExecuting.debounce(0, scheduler: MainScheduler.instance).subscribe(onNext: { [weak self] executing in
if (executing) {
self?.activityIndicator.startAnimating()
}
Expand Down
14 changes: 11 additions & 3 deletions Sources/Action/Action.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public final class Action<Input, Element> {
public let elements: Observable<Element>

/// Whether or not we're currently executing.
public let executing: Observable<Bool>
public let isExecuting: Observable<Bool>

/// Observables returned by the workFactory.
/// Useful for sending results back from work being completed
Expand Down Expand Up @@ -87,7 +87,7 @@ public final class Action<Input, Element> {
elements = executionObservables
.flatMap { $0.catchError { _ in Observable.empty() } }

executing = executionObservables.flatMap {
isExecuting = executionObservables.flatMap {
execution -> Observable<Bool> in
let execution = execution
.flatMap { _ in Observable<Bool>.empty() }
Expand All @@ -101,7 +101,7 @@ public final class Action<Input, Element> {
.share(replay: 1, scope: .forever)

Observable
.combineLatest(executing, enabledIf) { !$0 && $1 }
.combineLatest(isExecuting, enabledIf) { !$0 && $1 }
.bind(to: enabledSubject)
.disposed(by: disposeBag)
}
Expand Down Expand Up @@ -129,3 +129,11 @@ public final class Action<Input, Element> {
return subject.asObservable()
}
}

// MARK: Deprecated
extension Action {
@available(*, deprecated, renamed: "isExecuting")
public var executing: Observable<Bool> {
return isExecuting
}
}
4 changes: 2 additions & 2 deletions Tests/ActionTests/ActionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ActionTests: QuickSpec {
.bind(to: enabled)
.disposed(by: disposeBag)

action.executing
action.isExecuting
Copy link

Choose a reason for hiding this comment

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

Wrong indentation

.bind(to: executing)
.disposed(by: disposeBag)

Expand All @@ -90,7 +90,7 @@ class ActionTests: QuickSpec {
action.elements.subscribe().disposed(by: disposeBag)
action.errors.subscribe().disposed(by: disposeBag)
action.enabled.subscribe().disposed(by: disposeBag)
action.executing.subscribe().disposed(by: disposeBag)
action.isExecuting.subscribe().disposed(by: disposeBag)
Copy link

Choose a reason for hiding this comment

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

Wrong indentation

action.executionObservables.subscribe().disposed(by: disposeBag)
}

Expand Down