Completed
Push — master ( 43650d...3e5f45 )
by Chris
01:14
created

my.runCallbacks   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
jsondash.api = function(){
0 ignored issues
show
Bug introduced by
The variable jsondash seems to be never declared. If this is a global, consider adding a /** global: jsondash */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
2
    var callbacks = {};
3
    var my = {};
4
    my.listCallbacks = function() {
5
        return callbacks;
6
    };
7
    my.registerCallback = function(guid, cb, args) {
8
        var cb_obj = {callback: cb, args: args};
9
        if(!callbacks[guid]) {
10
            callbacks[guid] = [cb_obj];
11
        } else {
12
            callbacks[guid].push(cb_obj);
13
        }
14
    }
15
    my.runCallbacks = function(container, config) {
16
        var cbs = callbacks[config.guid];
17
        if(cbs) {
18
            $.each(cbs, function(i, cb_config){
19
                cb_config.callback(container, config, cb_config.args);
20
            });
21
        }
22
    }
23
    return my;
24
}();
25