Sha256: 145c82af6f1119798e8b53663e20695a05500b6ea0894a44bfd2727aa3471852

Contents?: true

Size: 1.23 KB

Versions: 72

Compression:

Stored size: 1.23 KB

Contents

/**
 *  Class NotificationCenter
 */

var NotificationCenter = function() {
    var self = {};


    var _callbacks = [];


    /** PUBLIC FUNCTIONS**/

    /**

     */
    self.subscribe = function(notification, callback) {
        _callbacks.push({notification : notification, callback : callback});
    };

    self.unsubscribe = function(notification, callback) {
        var index = -1;
        for(var i=0; i<_callbacks.length; i++) {
            var c = _callbacks[i];
            if(c.notification == notification &&
                c.callback == callback) {
                index = i;
                break;
            }
        }
        if(index >= 0) {
            _callbacks.splice(index,1);
            return true;
        }
        else {
            return false;
        }


    };

    self.dispatch = function(notification) {
        console.log("Notification center > dispatch: "+notification);
        _.filter(_callbacks,
            function(c){return c.notification === notification})
            .forEach(
            function(c){c.callback();}
        );
    };



    var init = function() {

        //initialization stuff

    }();

    return self;
};

//global notification center
var notificationCenter = NotificationCenter();

Version data entries

72 entries across 36 versions & 1 rubygems

Version Path
nutella_framework-0.7.3 framework_components/monitoring-interface/js/notification/notification-center.js
nutella_framework-0.7.3 framework_components/monitoring-interface/css/Monitoring Interface_files/notification-center.js
nutella_framework-0.7.2 framework_components/monitoring-interface/css/Monitoring Interface_files/notification-center.js
nutella_framework-0.7.2 framework_components/monitoring-interface/js/notification/notification-center.js
nutella_framework-0.7.1 framework_components/monitoring-interface/js/notification/notification-center.js
nutella_framework-0.7.1 framework_components/monitoring-interface/css/Monitoring Interface_files/notification-center.js
nutella_framework-0.7.0 framework_components/monitoring-interface/js/notification/notification-center.js
nutella_framework-0.7.0 framework_components/monitoring-interface/css/Monitoring Interface_files/notification-center.js
nutella_framework-0.6.21 framework_components/monitoring-interface/css/Monitoring Interface_files/notification-center.js
nutella_framework-0.6.21 framework_components/monitoring-interface/js/notification/notification-center.js
nutella_framework-0.6.20 framework_components/monitoring-interface/css/Monitoring Interface_files/notification-center.js
nutella_framework-0.6.20 framework_components/monitoring-interface/js/notification/notification-center.js
nutella_framework-0.6.19 framework_components/monitoring-interface/css/Monitoring Interface_files/notification-center.js
nutella_framework-0.6.19 framework_components/monitoring-interface/js/notification/notification-center.js
nutella_framework-0.6.18 framework_components/monitoring-interface/js/notification/notification-center.js
nutella_framework-0.6.18 framework_components/monitoring-interface/css/Monitoring Interface_files/notification-center.js
nutella_framework-0.6.17 framework_components/monitoring-interface/js/notification/notification-center.js
nutella_framework-0.6.17 framework_components/monitoring-interface/css/Monitoring Interface_files/notification-center.js
nutella_framework-0.6.16 framework_components/monitoring-interface/js/notification/notification-center.js
nutella_framework-0.6.16 framework_components/monitoring-interface/css/Monitoring Interface_files/notification-center.js