-
Notifications
You must be signed in to change notification settings - Fork 150
Description
Hi guys,
thanks for this great library, lack of actions was preventing me to move from RAC to RX :)
I've bootstrapped a project with RxSwift and Action, cocoapods chose RxSwift 3.1 which should be compatible with the latest version of Action.
It seems that the "executing" state of the Action doesn't get properly updated when the Observable returned is created with .just() and execute()d with parameters.
Seems that this block of code
let executionStart = executionObservables
let executionEnd = executionObservables
.flatMap { observable -> Observable<Void> in
return observable
.flatMap { _ in Observable<Void>.empty() }
.concat(Observable.just())
.catchErrorJustReturn()
}
executing = Observable
.of(executionStart.map { _ in true }, executionEnd.map { _ in false })
.merge()
.startWith(false)
is not respecting the expected "order" of executionStart and executionEnd, and the true of the executingStart observable is being sent AFTER the executingEnd's false
This is currently preventing me from using the same action more than once in my project (the secondo time I execute the action, it's still disabled because of wrong value sent by the executing observable).
I've also checked the tests:
context("trigger via execute() method")
is failing twice in your test suite, (line 138 and 297 of ActionTest.swift) with something like this
XCTAssertEqual failed: ("[next(false) @ 0, next(false) @ 10, next(true) @ 10, next(false) @ 20, next(true) @ 20]") is not equal to ("[next(false) @ 0, next(true) @ 10, next(false) @ 10, next(true) @ 20, next(false) @ 20]")
As you can see, we have false(10) BEFORE true(10). I would expect (and so do the tests) to see true(10) (executing) and then false(10) (finished executing).
I have a good experience with ReactiveCocoa/ReactiveSwift but I'm quite unexperienced with RxSwift (although they're seem almost identical to me). I don't know what clever trick could allow us to sort this out, I've tried with a delay of 0.0 seconds on the executionEnd observable, it seems to works for my purposes (== in my project) but is breaking almost ALL the tests XD
Thanks