/**
 * Created by Benny on 12.10.2014.
 */

"use strict";

var TB = TB || {};

// Global Data
TB.GD =  {

    ed : null,//new TB.EventDispatcher(),
    values : new Object(),

    get : function( key ) {
        if ( this.values.hasOwnProperty( key ) ) {
            return this.values[ key ];
        } else {
            return null;
        }
    },

    set : function( key, value ) {
        var old = this.get( key );
        if ( old === value ) return;
        this.values[ key ] = value;
        this.ed.emit( 'value_change_' + key , { old: old, new: value } );
        this.ed.emit( 'value_change', {key : key, old: old, new: value } );
    },

    watch : function( key, callback, scope ) {
        if ( key ) {
            this.ed.register( 'value_change_' + key, scope, callback );
        } else {
            this.ed.register( 'value_change', scope, callback );
        }
    },

    // @todo
    unwatch : function( key, callback ) {
        if ( key ) {

        } else {

        }
    }
};