mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 05:59:21 +03:00
*.jsx -> *.js
This commit is contained in:
parent
0a2b826f71
commit
e88c193334
98 changed files with 341 additions and 340 deletions
52
dev/Common/Events.js
Normal file
52
dev/Common/Events.js
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
|
||||
import _ from '_';
|
||||
import {isObject, isUnd} from 'Common/Utils';
|
||||
import * as Plugins from 'Common/Plugins';
|
||||
|
||||
const SUBS = {};
|
||||
|
||||
/**
|
||||
* @param {string|Object} name
|
||||
* @param {Function} func
|
||||
* @param {Object=} context
|
||||
*/
|
||||
export function sub(name, func, context)
|
||||
{
|
||||
if (isObject(name))
|
||||
{
|
||||
context = func || null;
|
||||
func = null;
|
||||
|
||||
_.each(name, (subFunc, subName) => {
|
||||
sub(subName, subFunc, context);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isUnd(SUBS[name]))
|
||||
{
|
||||
SUBS[name] = [];
|
||||
}
|
||||
|
||||
SUBS[name].push([func, context]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {Array=} args
|
||||
*/
|
||||
export function pub(name, args)
|
||||
{
|
||||
Plugins.runHook('rl-pub', [name, args]);
|
||||
|
||||
if (!isUnd(SUBS[name]))
|
||||
{
|
||||
_.each(SUBS[name], (items) => {
|
||||
if (items[0])
|
||||
{
|
||||
items[0].apply(items[1] || null, args || []);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue