`observe(on:)` doesn't run on the given scheduler.
zebganzo opened this issue · comments
Hi all!
In my code, I have an Action
created in the main
thread that I need to run on a background
scheduler.
This is how it looks like:
let anAction = Action { (Void) -> SignalProducer<Void, Error> in
return SignalProducer<Void, Error> { observer, _ in
// Some magic code
}
}
If I call the action in this way, my magic code runs on the main
tread`:
anAction.apply(()).observe(on: scheduler).start()
Instead, in this case, it runs on the given scheduler.
anAction.apply(()).start(on: scheduler).start()
How come? Is it how it's supposed to work or is it a bug?
Yes, that's the difference between .start(on:)
and .observe(on:)
. 🙂
Good to know! I personally found the description a bit misleading.
Forward all events onto the given scheduler, instead of whichever scheduler they originally arrived upon.
What is supposed to do then?
Thanks for the quick answer 😉