The current middleware system of channels.EventBus remembers the order of the middlewares, which is usually crucial to getting the correct data across. It does not, however, allow insertion at any position, which is sometimes desirable.
Also, O(1) insertion and removal of middlewares means that the middleware must be a hashable callable. For unhashable callables, functions must be made to wrap them, which is annoying.
Besides, the underlying implementation (using a hash map) disallows duplicate middlewares. Again, to work around this, wrapper functions must be used in place of the function containing the processing steps. This is troublesome.
However, a method to get the best of both worlds (performance and flexibility) is not known.
The current middleware system of channels.EventBus remembers the order of the middlewares, which is usually crucial to getting the correct data across. It does not, however, allow insertion at any position, which is sometimes desirable.
Also, O(1) insertion and removal of middlewares means that the middleware must be a hashable callable. For unhashable callables, functions must be made to wrap them, which is annoying.
Besides, the underlying implementation (using a hash map) disallows duplicate middlewares. Again, to work around this, wrapper functions must be used in place of the function containing the processing steps. This is troublesome.
However, a method to get the best of both worlds (performance and flexibility) is not known.