-
I was trying to use this for testing, as shown in your examples, but my coded uses the queue both for |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @JetForMe, this is a good question! Unfortunately it is not safe to expose a dispatch queue inside the The best we could do is expose a Having said that, you can still accomplish what you want without getting access to the underlying scheduler. The scheduler.schedule {
// do work
} Best of all, this works for all schedulers, whether you are really using a dispatch queue, test scheduler, immediate scheduler, etc. |
Beta Was this translation helpful? Give feedback.
Hey @JetForMe, this is a good question!
Unfortunately it is not safe to expose a dispatch queue inside the
AnyScheduler
because it's not necessarily always powered by a real life dispatch queue. You can have aAnySchedulerOf<DispatchQueue>
that secretly is a test scheduler or immediate scheduler under the hood, and so there is not real dispatch queue to expose.The best we could do is expose a
var base: Any
that exposes the underlying scheduler, but it would have to beAny
because the type of the underlying scheduler has been completely forgotten about... which is the point of theAnyScheduler
. But, if you try casting thatAny
to aDispatchQueue
it will fail in tests because most likely y…