Manipulate Interceptors on a Call?
We were looking at some Wire stuff, and Wire operates on a Call.Factory so it cannot introduce new interceptors to an existing Call.
It’d be interesting/powerful to be able to add interceptors directly on a Call instance.
application or network interceptors? both?
Both
This is a weird mixing of layers, but I can see why it's powerful. Particularly if we increasingly support Call.Factory as API and also as implementation.
But in that regard it's why it's mixing the layers. Call.Factory and dependencies are fairly tight. It would pull in Interceptor, and transitively Chain, Connection.
I guess we could ignore this except on jvm.
What is the contract, that you can add final application or network interceptors? Any need to be in other positions?
This seems doable, but Call is a pretty central public API that is actively implemented. So wondering what the APIs are like, going to throw in EventListeners here also.
Can't work out how to do this nicely with a clone, since RealCall is heavyweight.
interface Call {
fun clone(xxx): Call
}
So maybe
interface Call {
fun addEventListener(eventListener: EventListener)
fun addInterceptor(interceptor: Interceptor)
fun addNetworkInterceptor(interceptor: Interceptor)
}
Or
interface Call {
// must be called before execution
fun reconfigure(fn: CallOptions.() -> Unit)
}
interface CallOptions {
fun addEventListener(eventListener: EventListener)
var interceptors: List<Interceptor>
var networkInterceptors: List<Interceptor>
}
Or interface ConfigurableCall: Call