Skip to content

Commit

Permalink
Conflict resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
LucianoPAlmeida committed May 1, 2019
2 parents 8cbc173 + cb8a78a commit 96ac908
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
6 changes: 4 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ Changelog

Current master
--------------
- Add `completions` property to `CompletableAction`

3.11.0
-------
- Introduction of `underlyingError` observable which returns a `Swift.Error` element type.
- Updated specs that were breaking in `Circle CI` pipeline
- Introduction of `underlyingError` observable which returns a `Swift.Error` element type.
- Updated specs that were breaking in `Circle CI` pipeline

3.10.2
-------
Expand Down
11 changes: 11 additions & 0 deletions Sources/Action/Action+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,14 @@ public extension Action where Input == Void {
return execute(())
}
}

public extension CompletableAction {
/// Emits everytime work factory completes.
var completions: Observable<Void> {
return executionObservables
.flatMap { execution in
execution.flatMap { _ in Observable.empty() }
.concat(Observable.just(()))
}
}
}
11 changes: 9 additions & 2 deletions Tests/ActionTests/ActionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class ActionTests: QuickSpec {
describe("completable action") {
var action: CompletableAction<String>!
beforeEach {
let work: Completable = Observable<Never>.empty().asCompletable()
action = CompletableAction {_ in work }
let work: TestableObservable<Never> = scheduler.createColdObservable([.completed(0)])
action = CompletableAction {_ in work.asCompletable() }
scheduler.scheduleAt(10) { action.inputs.onNext("a") }
scheduler.scheduleAt(20) { action.inputs.onNext("b") }
}
Expand All @@ -41,6 +41,13 @@ class ActionTests: QuickSpec {
scheduler.start()
XCTAssertEqual(elements.events.count, 0)
}
it("emits on `completions` when completed") {
let completions = scheduler.createObserver(Void.self)
action.completions.bind(to: completions).disposed(by: disposeBag)
scheduler.start()
XCTAssert(completions.events.contains { $0.time == 10})
XCTAssert(completions.events.contains { $0.time == 20})
}
}

describe("action properties") {
Expand Down

0 comments on commit 96ac908

Please sign in to comment.