addSSEInterceptor method
Add SSE interceptor to listen sse dispatch. usually receive sse from cache pool, sse will dispatch to SSEInterceptor.intercept
if need to receive from server sse immediately, please refer SSEInterceptor.isPeek parameter.
isOnly represent interceptor don't support add multiple times by same SSEInterceptor.name.
Implementation
void addSSEInterceptor(SSEInterceptor interceptor, {bool isOnly = false}) {
bool result = _interceptorManager.addSSEInterceptor(interceptor, isOnly: isOnly);
if (result) {
if (interceptor.isPeek) {
_sseCacheDeliverer.flushPeek(pop: (sseC) {
_interceptorManager.deliver(sseC, isPeek: true);
});
}
_sseCacheDeliverer.flush(pop: _deliverSSEC, breakLoop: true);
}
}