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

Change inputs type to AnyObserver<Input> #193

Merged
merged 5 commits into from
Apr 23, 2019
Merged
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
Prev Previous commit
Next Next commit
change inputs type to AnyObserver<Input>
mosamer committed Apr 22, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit db7694ac21e9e7a504f03e33213398c85310f4e3
13 changes: 7 additions & 6 deletions Sources/Action/Action.swift
Original file line number Diff line number Diff line change
@@ -22,11 +22,9 @@ When this excuted via execute() or inputs subject, it passes its parameter to th
public final class Action<Input, Element> {
public typealias WorkFactory = (Input) -> Observable<Element>

/// Inputs that triggers execution of action.
/// This subject also includes inputs as aguments of execute().
/// All inputs are always appear in this subject even if the action is not enabled.
/// Thus, inputs count equals elements count + errors count.
public let inputs = InputSubject<Input>()

/// Bindable sink for inputs that triggers execution of action.
public let inputs: AnyObserver<Input>

/// Errors aggrevated from invocations of execute().
/// Delivered on whatever scheduler they were sent from.
@@ -70,7 +68,10 @@ public final class Action<Input, Element> {
let errorsSubject = PublishSubject<ActionError>()
errors = errorsSubject.asObservable()

executionObservables = inputs
let inputsSubject = InputSubject<Input>()
inputs = inputsSubject.asObserver()

executionObservables = inputsSubject
.withLatestFrom(isEnabled) { input, enabled in (input, enabled) }
.flatMap { input, enabled -> Observable<Observable<Element>> in
if enabled {
2 changes: 1 addition & 1 deletion Tests/ActionTests/ActionTests.swift
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ class ActionTests: QuickSpec {
}
}

describe("Input subject behavior") {
describe("Input observer behavior") {
var action: Action<String, String>!
var inputs: TestableObserver<String>!
var executions: TestableObserver<Observable<String>>!