function FrameObserver() {
    this.fns = [];
}

FrameObserver.prototype = {
    subscribe : function(msg, fn) {
      if (!this.fns[msg]){
        this.fns[msg] = [];
      }
      
      this.fns[msg].push(fn);
    },
    unsubscribe : function(msg, fn) {
        this.fns[msg] = this.fns[msg].filter(
            function(el) {
                if ( el !== fn ) {
                    return el;
                }
            }
        );
    },
    send : function(msg, payload, thisObj) {
        if (!this.fns[msg]) { return }
      
        var scope = thisObj || window;
        for (var i = 0; i < this.fns[msg].length; i++) {
            this.fns[msg][i].call(scope, payload);
        };
    }
};
