Use cases for the queue in interceptors?

Another use case would be to provide hooks into a library for its consumer to provide interceptors when they normally would not be accessible.

re-flow is a re-frame library that implements this use case. It provides an event handler for an event that will ultimately be dispatched outside the library by the application.

However, it is possible (maybe even likely) that the calling application will want to inject custom behavior to be run with the event. However, since the event handler is implemented inside the library, there is no direct way to specify an interceptor on it.

To address this issue, re-flow provides a mechanism for an application to register the interceptors it would like to run with that event. Internally, it uses a custom interceptor that simply pushes the registered interceptors onto the queue.

You can see an example of its use here.

1 Like