Skip to content

Instantly share code, notes, and snippets.

@BenHenning
Created October 15, 2020 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenHenning/4245500a22189f579d3179bbfcced0af to your computer and use it in GitHub Desktop.
Save BenHenning/4245500a22189f579d3179bbfcced0af to your computer and use it in GitHub Desktop.
fun <A: Activity, R> ActivityScenario<T>.letInActivity(callback: (A) -> R): R {
data class NullWrapper<T>(val value: T)
lateinit var result: NullWrapper<R>
onActivity { activity -> result = NullWrapper(callback(activity)) }
return result.value
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment