BehaviorBase.js 916 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import onfire from 'onfire';
  2. export default class BehaviorBase
  3. {
  4. constructor(behaviorName)
  5. {
  6. this._name = behaviorName;
  7. this._guid = onfire.getGuid();
  8. this._slice = Function.call.bind(Array.prototype.slice);
  9. }
  10. getBehaviorName()
  11. {
  12. return this._name;
  13. }
  14. on(evntName,handler,context)
  15. {
  16. return onfire.on(evntName ,handler,context);
  17. }
  18. off(event)
  19. {
  20. var type = typeof event;
  21. if (type === 'string') {
  22. onfire.un(attributeName);
  23. }
  24. else if (type === 'object' || type === 'function') {
  25. onfire.un(event);
  26. }
  27. }
  28. onDestoy()
  29. {
  30. }
  31. destroy()
  32. {
  33. onfire.fireSync('destroy',this);
  34. this.onDestoy();
  35. }
  36. setData(msgId,pb)
  37. {
  38. }
  39. emit(eventName)
  40. {
  41. onfire.fireSync(eventName,this,this._slice(arguments,1));
  42. }
  43. }