
import onfire from 'onfire';

export default class BehaviorBase
{
    constructor(behaviorName)
    {
        this._name = behaviorName;
        this._guid = onfire.getGuid();
        this._slice = Function.call.bind(Array.prototype.slice);
    }

    getBehaviorName()
    {
        return this._name;
    }

    on(evntName,handler,context)
    {
        return onfire.on(evntName ,handler,context);
    }


    off(event)
    {
        var type = typeof event;
        if (type === 'string') {
           onfire.un(attributeName);
        }
        else if (type === 'object' || type === 'function') {
            onfire.un(event);
        }
    }


    onDestoy()
    {

    }

    destroy()
    {
        onfire.fireSync('destroy',this);
        this.onDestoy();
    }

    setData(msgId,pb)
    {

    }
    
    emit(eventName)
    {
       onfire.fireSync(eventName,this,this._slice(arguments,1));
    }

}
