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

Should executing be emitting false as first value ? #157

Open
c0diq opened this issue Oct 11, 2018 · 2 comments
Open

Should executing be emitting false as first value ? #157

c0diq opened this issue Oct 11, 2018 · 2 comments

Comments

@c0diq
Copy link

c0diq commented Oct 11, 2018

ReactiveCocoa contract was that the executing observable would emit false as a first value when subscribed to and the command was not executing. This would allow to directly use it in the enabledIf of another opposite action. Instead we have to manually send false which can have side effects if the action is actually executing.

let stopAction = Action<(), ()> { _ in .just(()) }
let startAction = Action<(), ()>(enabledIf: stopAction.startWith(false).not()) { _ in
   .just(())
}

Instead of

let stopAction = Action<(), ()> { _ in .just(()) }
let startAction = Action<(), ()>(enabledIf: stopAction.not()) { _ in
   .just(())
}
@ashfurrow
Copy link
Member

That makes sense to me – are you able to open a PR adding this behaviour (and a test)?

@c0diq c0diq changed the title Should executing emits false as first value ? Should executing emit false as first value ? Oct 12, 2018
@c0diq c0diq changed the title Should executing emit false as first value ? Should executing be emitting false as first value ? Oct 12, 2018
@dangthaison91
Copy link
Contributor

@c0diq Just do a quick check and executing always emit false first? You can refer to this line of code:

.startWith(false)

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

No branches or pull requests

3 participants