forked from RainLoop/rainloop-webmail
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEvents.js
More file actions
52 lines (45 loc) · 801 Bytes
/
Copy pathEvents.js
File metadata and controls
52 lines (45 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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 || []);
}
});
}
}