Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
jitsi-meet/react/features/base/redux/MiddlewareRegistry.js

61 lines
1.6 KiB

/* @flow */
import { applyMiddleware } from 'redux';
import type { Middleware } from 'redux';
/**
* A registry for Redux middleware, allowing features to register their
* middleware without needing to create additional inter-feature dependencies.
*/
class MiddlewareRegistry {
_elements: Array<Middleware<*, *>>;
/**
* Creates a MiddlewareRegistry instance.
*/
constructor() {
/**
* The set of registered middleware.
*
* @private
* @type {Middleware[]}
*/
this._elements = [];
}
/**
* Applies all registered middleware into a store enhancer.
* (@link http://redux.js.org/docs/api/applyMiddleware.html).
*
* @param {Middleware[]} additional - Any additional middleware that need to
* be included (such as middleware from third-party modules).
* @returns {Middleware}
*/
applyMiddleware(...additional: Array<Middleware<*, *>>) {
// XXX The explicit definition of the local variable middlewares is to
// satisfy flow.
const middlewares = [
...this._elements,
...additional
];
return applyMiddleware(...middlewares);
}
/**
* Adds a middleware to the registry.
*
* The method is to be invoked only before {@link #applyMiddleware()}.
*
* @param {Middleware} middleware - A Redux middleware.
* @returns {void}
*/
register(middleware: Middleware<*, *>) {
this._elements.push(middleware);
}
}
/**
* The public singleton instance of the MiddlewareRegistry class.
*/
export default new MiddlewareRegistry();