mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 14:07:04 +03:00
Added back base for simple plugins hooks
This commit is contained in:
parent
fe4dbc729c
commit
830fa5b753
4 changed files with 57 additions and 1 deletions
|
|
@ -1,9 +1,34 @@
|
|||
import { settingsAddViewModel } from 'Screen/AbstractSettings';
|
||||
import { SettingsGet } from 'Common/Globals';
|
||||
import { isArray, isFunction } from 'Common/Utils';
|
||||
|
||||
const USER_VIEW_MODELS_HOOKS = [],
|
||||
const SIMPLE_HOOKS = {},
|
||||
USER_VIEW_MODELS_HOOKS = [],
|
||||
ADMIN_VIEW_MODELS_HOOKS = [];
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {Function} callback
|
||||
*/
|
||||
rl.addHook = (name, callback) => {
|
||||
if (isFunction(callback)) {
|
||||
if (!isArray(SIMPLE_HOOKS[name])) {
|
||||
SIMPLE_HOOKS[name] = [];
|
||||
}
|
||||
SIMPLE_HOOKS[name].push(callback);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {Array=} args = []
|
||||
*/
|
||||
export function runHook(name, args = []) {
|
||||
if (isArray(SIMPLE_HOOKS[name])) {
|
||||
SIMPLE_HOOKS[name].forEach(callback => callback(...args));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Function} callback
|
||||
* @param {string} action
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue