Home Reference Source

cables_dev/cables/src/core/sessionvar.js

  1. // todo: old... remove this from ops...
  2.  
  3. /**
  4. * todo: old... remove this from ops...
  5. *
  6. * @class
  7. */
  8. const Variable = function ()
  9. {
  10. let value = null;
  11. const changedCallbacks = [];
  12.  
  13. this.onChanged = function (f)
  14. {
  15. changedCallbacks.push(f);
  16. };
  17.  
  18. this.getValue = function ()
  19. {
  20. return value;
  21. };
  22.  
  23. this.setValue = function (v)
  24. {
  25. value = v;
  26. this.emitChanged();
  27. };
  28.  
  29. this.emitChanged = function ()
  30. {
  31. for (let i = 0; i < changedCallbacks.length; i++)
  32. {
  33. changedCallbacks[i]();
  34. }
  35. };
  36. };
  37.  
  38. export { Variable };