Closed plnice closed 3 years ago
Hi there! Thanks for the question. Generally, you can easily make your own extension function with your interceptor inside. Something like this:
fun <T: Screen> onInterceptedScreen(receiver: T.() -> Unit) {
myInterceptor()
onScreen<T>(receiver)
}
Yes, but this solution has two drawbacks:
onScreen
provided by the library - if somebody uses onScreen
by mistake, she won't get any warning or compilation error and our interceptor won't be calledonInterceptedScreen
methods added or a need to add an abstract screen implementation with method providing the interceptorWhat we also thought about was extending the intercept
with onFirst
functionality which would fire the interceptor only once:
intercept {
onViewInteraction {
onFirst {
...
}
}
}
In that case you should just define another interceptor holder:
intercept {
onFirstViewInteraction {
...
}
}
You are welcome to submit a PR with such implementation 👍
Closing this issue due to no activity. You can reopen issue if it is not solved yet.
Hi, we want to set up a screen interceptor which would be fired when screen becomes active - only once, before running the function passed to
onScreen
method. In our case the interceptor is heavy and time-consuming and we don't need to invoke it on each check/perform. Would there be a possibility to add such a functionality/would you accept a pull request with such functionality? The other option which probably would work for us is to make the screen'sinvoke
operator open so that we can override it and perform our code before running the function.