As an intermediate step on the path to merging jitsi-meet and
jitsi-meet-react, import the whole source code of jitsi-meet-react as it
stands at
2f23d98424
i.e. the lastest master at the time of this import. No modifications are
applied to the imported source code in order to preserve a complete
snapshot of it in the repository of jitsi-meet and, thus, facilitate
comparison later on. Consequently, the source code of jitsi-meet and/or
jitsi-meet-react may not work. For example, jitsi-meet's jshint may be
unable to parse jitsi-meet-react's source code.
50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
import { applyMiddleware } from 'redux';
|
|
|
|
/**
|
|
* A registry for Redux middleware, allowing features to register their
|
|
* middleware without needing to create additional inter-feature dependencies.
|
|
*/
|
|
class MiddlewareRegistry {
|
|
/**
|
|
* Creates a MiddlewareRegistry instance.
|
|
*/
|
|
constructor() {
|
|
/**
|
|
* The set of registered middleware.
|
|
*/
|
|
this.middlewareRegistry = new Set();
|
|
}
|
|
|
|
/**
|
|
* Applies all registered middleware into a store enhancer.
|
|
* (@link http://redux.js.org/docs/api/applyMiddleware.html).
|
|
*
|
|
* @param {Function[]} additional - Any additional middleware that need to
|
|
* be included (such as middleware from third-party modules).
|
|
* @returns {Function}
|
|
*/
|
|
applyMiddleware(...additional) {
|
|
return applyMiddleware(
|
|
...this.middlewareRegistry,
|
|
...additional
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Adds a middleware to the registry.
|
|
*
|
|
* The method is to be invoked only before {@link #applyMiddleware()}.
|
|
*
|
|
* @param {Function} middleware - A Redux middleware.
|
|
* @returns {void}
|
|
*/
|
|
register(middleware) {
|
|
this.middlewareRegistry.add(middleware);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* The public singleton instance of the MiddlewareRegistry class.
|
|
*/
|
|
export default new MiddlewareRegistry();
|