Skip to content

How to detect if a CoroutineDispatcher is suspended due to a delay? #1919

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

Closed
ZakTaccardi opened this issue Apr 17, 2020 · 1 comment
Closed
Labels

Comments

@ZakTaccardi
Copy link

I want to be able to inform Espresso that it should not consider itself idle when there is an active coroutine with a specific name that is suspend due to a delay(..).

idlingDispatchers.reportNotIdleWhileCoroutineIsDelayed(
  CoroutineName("my_coroutine")
)

One way to achieve this would be to inject a custom delay(..) function, but I would prefer to avoid that to keep production code simple.

The difficulty I'm having is that I want to leverage the default behavior of DefaultDelay (which is internal) unless I am attempting to monitor a specific CoroutineName for idle.

@elizarov
Copy link
Contributor

You can inject this behavior in a custom CoroutineDispatcher implementation by implementing a Delay interface, in which case the delay(...) function delegates to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants